Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76295 - in trunk/libs/thread/test: sync sync/conditions sync/conditions/condition_variable sync/conditions/condition_variable_any sync/conditions/cv_status sync/futures sync/futures/async sync/futures/errors sync/futures/future sync/futures/future_errc sync/futures/future_errors sync/futures/future_status sync/futures/packaged_task sync/futures/promise sync/futures/shared_future sync/mutual_exclusion sync/mutual_exclusion/barrier sync/mutual_exclusion/lock_algorithm sync/mutual_exclusion/lock_algorithm/lock sync/mutual_exclusion/lock_algorithm/try_lock sync/mutual_exclusion/locks sync/mutual_exclusion/locks/lock_guard sync/mutual_exclusion/locks/shared_lock sync/mutual_exclusion/locks/unique_lock sync/mutual_exclusion/locks/unique_lock/cons sync/mutual_exclusion/locks/unique_lock/locking sync/mutual_exclusion/locks/unique_lock/mod sync/mutual_exclusion/locks/unique_lock/obs sync/mutual_exclusion/locks/upgrade_lock sync/mutual_exclusion/locks/upgrade_to_unique_lock sync/mutual_exclusion/mutex sync/mutual_exclusion/once sync/mutual_exclusion/once/call_once sync/mutual_exclusion/once/once_flag sync/mutual_exclusion/recursive_mutex sync/mutual_exclusion/recursive_timed_mutex sync/mutual_exclusion/shared_mutex sync/mutual_exclusion/timed_mutex threads threads/this_thread threads/this_thread/at_thread_exit threads/this_thread/disable_interruption threads/this_thread/get_id threads/this_thread/interruption_enabled threads/this_thread/interruption_point threads/this_thread/interruption_requested threads/this_thread/restore_interruption threads/this_thread/sleep_for threads/this_thread/sleep_until threads/this_thread/yield threads/thread threads/thread/assign threads/thread/attributes threads/thread/constr threads/thread/destr threads/thread/id threads/thread/members threads/thread/non_members threads/thread/static threads/thread_group
From: vicente.botet_at_[hidden]
Date: 2012-01-03 16:23:19


Author: viboes
Date: 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
New Revision: 76295
URL: http://svn.boost.org/trac/boost/changeset/76295

Log:
Threads: Added a lot of unit tests
Added:
   trunk/libs/thread/test/sync/
   trunk/libs/thread/test/sync/conditions/
   trunk/libs/thread/test/sync/conditions/condition_variable/
   trunk/libs/thread/test/sync/conditions/condition_variable/assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/dtor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/native_handle_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/wait_for_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/wait_for_pred_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/wait_until_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable/wait_until_pred_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/
   trunk/libs/thread/test/sync/conditions/condition_variable_any/assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/dtor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_for_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_for_pred_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_until_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_until_pred_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/conditions/cv_status/
   trunk/libs/thread/test/sync/conditions/cv_status/cv_status_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/futures/
   trunk/libs/thread/test/sync/futures/async/
   trunk/libs/thread/test/sync/futures/async/async_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/futures/errors/
   trunk/libs/thread/test/sync/futures/future/
   trunk/libs/thread/test/sync/futures/future_errc/
   trunk/libs/thread/test/sync/futures/future_errors/
   trunk/libs/thread/test/sync/futures/future_status/
   trunk/libs/thread/test/sync/futures/packaged_task/
   trunk/libs/thread/test/sync/futures/promise/
   trunk/libs/thread/test/sync/futures/shared_future/
   trunk/libs/thread/test/sync/mutual_exclusion/
   trunk/libs/thread/test/sync/mutual_exclusion/barrier/
   trunk/libs/thread/test/sync/mutual_exclusion/lock_algorithm/
   trunk/libs/thread/test/sync/mutual_exclusion/lock_algorithm/lock/
   trunk/libs/thread/test/sync/mutual_exclusion/lock_algorithm/try_lock/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/
   trunk/libs/thread/test/sync/mutual_exclusion/locks/upgrade_to_unique_lock/
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/native_handle_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/mutex/try_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/once/
   trunk/libs/thread/test/sync/mutual_exclusion/once/call_once/
   trunk/libs/thread/test/sync/mutual_exclusion/once/once_flag/
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/native_handle_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/native_handle_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_for_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_until_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/shared_mutex/
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/native_handle_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/
   trunk/libs/thread/test/threads/this_thread/
   trunk/libs/thread/test/threads/this_thread/at_thread_exit/
   trunk/libs/thread/test/threads/this_thread/disable_interruption/
   trunk/libs/thread/test/threads/this_thread/get_id/
   trunk/libs/thread/test/threads/this_thread/get_id/get_id_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/this_thread/interruption_enabled/
   trunk/libs/thread/test/threads/this_thread/interruption_point/
   trunk/libs/thread/test/threads/this_thread/interruption_requested/
   trunk/libs/thread/test/threads/this_thread/restore_interruption/
   trunk/libs/thread/test/threads/this_thread/sleep_for/
   trunk/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/this_thread/sleep_until/
   trunk/libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/this_thread/yield/
   trunk/libs/thread/test/threads/thread/
   trunk/libs/thread/test/threads/thread/assign/
   trunk/libs/thread/test/threads/thread/assign/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/assign/move_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/attributes/
   trunk/libs/thread/test/threads/thread/constr/
   trunk/libs/thread/test/threads/thread/constr/F_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/constr/copy_fail.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/constr/default_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/constr/move_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/destr/
   trunk/libs/thread/test/threads/thread/destr/dtor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/id/
   trunk/libs/thread/test/threads/thread/id/hash_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/members/
   trunk/libs/thread/test/threads/thread/members/detach_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/members/get_id_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/members/join_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/members/joinable_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/members/native_handle_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/members/swap_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/non_members/
   trunk/libs/thread/test/threads/thread/non_members/swap_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread/static/
   trunk/libs/thread/test/threads/thread/static/hardware_concurrency_pass.cpp (contents, props changed)
   trunk/libs/thread/test/threads/thread_group/

Added: trunk/libs/thread/test/sync/conditions/condition_variable/assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable& operator=(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+
+int fail()
+{
+ boost::condition_variable cv0;
+ boost::condition_variable cv1;
+ cv1 = cv0;
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int fail()
+{
+ boost::condition_variable cv0;
+ boost::condition_variable cv1(cv0);
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::condition_variable cv0;
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/dtor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/dtor_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::condition_variable* cv;
+boost::mutex m;
+typedef boost::unique_lock<boost::mutex> Lock;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+ Lock lk(m);
+ f_ready = true;
+ cv->notify_one();
+ cv->wait(lk);
+ delete cv;
+}
+
+void g()
+{
+ Lock lk(m);
+ g_ready = true;
+ cv->notify_one();
+ while (!f_ready)
+ {
+ cv->wait(lk);
+ }
+ cv->notify_one();
+}
+
+int main()
+{
+ cv = new boost::condition_variable;
+ boost::thread th2(g);
+ Lock lk(m);
+ while (!g_ready)
+ {
+ cv->wait(lk);
+ }
+ lk.unlock();
+ boost::thread th1(f);
+ th1.join();
+ th2.join();
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/native_handle_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/native_handle_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ //BOOST_STATIC_ASSERT((boost::is_same<boost::condition_variable::native_handle_type, pthread_cond_t*>::value));
+ boost::condition_variable cv;
+ boost::condition_variable::native_handle_type h = cv.native_handle();
+ BOOST_TEST(h != 0);
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/wait_for_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/wait_for_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::condition_variable cv;
+boost::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds milliseconds;
+ boost::unique_lock<boost::mutex> lk(mut);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ while (test2 == 0 && cv.wait_for(lk, milliseconds(250)) == boost::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < milliseconds(250));
+ BOOST_TEST(test2 != 0);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - milliseconds(250) < milliseconds(5));
+ BOOST_TEST(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ boost::unique_lock<boost::mutex> lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ boost::unique_lock<boost::mutex> lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/wait_for_pred_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/wait_for_pred_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) :
+ i_(i)
+ {
+ }
+
+ bool operator()()
+ {
+ return i_ != 0;
+ }
+};
+
+boost::condition_variable cv;
+boost::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds milliseconds;
+ boost::unique_lock < boost::mutex > lk(mut);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < milliseconds(250));
+ BOOST_TEST(test2 != 0);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - milliseconds(250) < milliseconds(2));
+ BOOST_TEST(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ boost::unique_lock < boost::mutex > lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ boost::unique_lock < boost::mutex > lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/wait_until_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/wait_until_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct Clock
+{
+ typedef boost::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef boost::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace boost::chrono;
+ return time_point(duration_cast<duration> (steady_clock::now().time_since_epoch()));
+ }
+};
+
+boost::condition_variable cv;
+boost::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ boost::unique_lock < boost::mutex > lk(mut);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ while (test2 == 0 && cv.wait_until(lk, t) == boost::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < Clock::duration(250));
+ BOOST_TEST(test2 != 0);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - Clock::duration(250) < Clock::duration(5));
+ BOOST_TEST(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ boost::unique_lock < boost::mutex > lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ boost::unique_lock < boost::mutex > lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable/wait_until_pred_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable/wait_until_pred_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct Clock
+{
+ typedef boost::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef boost::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace boost::chrono;
+ return time_point(duration_cast<duration> (steady_clock::now().time_since_epoch()));
+ }
+};
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) :
+ i_(i)
+ {
+ }
+
+ bool operator()()
+ {
+ return i_ != 0;
+ }
+};
+
+boost::condition_variable cv;
+boost::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ boost::unique_lock<boost::mutex> lk(mut);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ bool r = cv.wait_until(lk, t, Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < Clock::duration(250));
+ BOOST_TEST(test2 != 0);
+ BOOST_TEST(r);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - Clock::duration(250) < Clock::duration(2));
+ BOOST_TEST(test2 == 0);
+ BOOST_TEST(!r);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ boost::unique_lock<boost::mutex> lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ boost::unique_lock<boost::mutex> lk(mut);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+
+int fail()
+{
+ boost::condition_variable_any cv0;
+ boost::condition_variable_any cv1;
+ cv1 = cv0;
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int fail()
+{
+ boost::condition_variable_any cv0;
+ boost::condition_variable_any cv1(cv0);
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::condition_variable_any cv0;
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/dtor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/dtor_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::condition_variable_any* cv;
+boost::timed_mutex m;
+typedef boost::unique_lock<boost::timed_mutex> Lock;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+ Lock lk(m);
+ f_ready = true;
+ cv->notify_one();
+ cv->wait(lk);
+ delete cv;
+}
+
+void g()
+{
+ Lock lk(m);
+ g_ready = true;
+ cv->notify_one();
+ while (!f_ready)
+ {
+ cv->wait(lk);
+ }
+ cv->notify_one();
+}
+
+int main()
+{
+ cv = new boost::condition_variable_any;
+ boost::thread th2(g);
+ Lock lk(m);
+ while (!g_ready)
+ {
+ cv->wait(lk);
+ }
+ lk.unlock();
+ boost::thread th1(f);
+ th1.join();
+ th2.join();
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_for_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_for_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::condition_variable_any cv;
+
+typedef boost::timed_mutex L0;
+typedef boost::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds milliseconds;
+ L1 lk(m0);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ while (test2 == 0 &&
+ cv.wait_for(lk, milliseconds(250)) == boost::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < milliseconds(250));
+ BOOST_TEST(test2 != 0);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - milliseconds(250) < milliseconds(5));
+ BOOST_TEST(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_for_pred_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_for_pred_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) :
+ i_(i)
+ {
+ }
+
+ bool operator()()
+ {
+ return i_ != 0;
+ }
+};
+
+boost::condition_variable_any cv;
+
+typedef boost::timed_mutex L0;
+typedef boost::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds milliseconds;
+ L1 lk(m0);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < milliseconds(250));
+ BOOST_TEST(test2 != 0);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - milliseconds(250) < milliseconds(5));
+ BOOST_TEST(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_until_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_until_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct Clock
+{
+ typedef boost::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef boost::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace boost::chrono;
+ return time_point(duration_cast<duration> (steady_clock::now().time_since_epoch()));
+ }
+};
+
+boost::condition_variable_any cv;
+
+typedef boost::timed_mutex L0;
+typedef boost::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ L1 lk(m0);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ while (test2 == 0 && cv.wait_until(lk, t) == boost::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < Clock::duration(250));
+ BOOST_TEST(test2 != 0);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - Clock::duration(250) < Clock::duration(5));
+ BOOST_TEST(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_until_pred_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/condition_variable_any/wait_until_pred_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/condition_variable_any>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct Clock
+{
+ typedef boost::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef boost::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace boost::chrono;
+ return time_point(duration_cast<duration> (steady_clock::now().time_since_epoch()));
+ }
+};
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) :
+ i_(i)
+ {
+ }
+
+ bool operator()()
+ {
+ return i_ != 0;
+ }
+};
+
+boost::condition_variable_any cv;
+
+typedef boost::timed_mutex L0;
+typedef boost::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ L1 lk(m0);
+ BOOST_TEST(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ bool r = cv.wait_until(lk, t, Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ BOOST_TEST(t1 - t0 < Clock::duration(250));
+ BOOST_TEST(test2 != 0);
+ BOOST_TEST(r);
+ }
+ else
+ {
+ BOOST_TEST(t1 - t0 - Clock::duration(250) < Clock::duration(2));
+ BOOST_TEST(test2 == 0);
+ BOOST_TEST(!r);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ boost::thread t(f);
+ BOOST_TEST(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ BOOST_TEST(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/conditions/cv_status/cv_status_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/conditions/cv_status/cv_status_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// static unsigned hardware_concurrency();
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ BOOST_TEST(boost::cv_status::no_timeout != boost::cv_status::timeout);
+ }
+ {
+ boost::cv_status st = boost::cv_status::no_timeout;
+ BOOST_TEST(st == boost::cv_status::no_timeout);
+ BOOST_TEST(boost::cv_status::no_timeout==st);
+ BOOST_TEST(st != boost::cv_status::timeout);
+ BOOST_TEST(boost::cv_status::timeout!=st);
+ }
+ {
+ boost::cv_status st = boost::cv_status::timeout;
+ BOOST_TEST(st == boost::cv_status::timeout);
+ BOOST_TEST(boost::cv_status::timeout==st);
+ BOOST_TEST(st != boost::cv_status::no_timeout);
+ BOOST_TEST(boost::cv_status::no_timeout!=st);
+ }
+ {
+ boost::cv_status st;
+ st = boost::cv_status::no_timeout;
+ BOOST_TEST(st == boost::cv_status::no_timeout);
+ BOOST_TEST(boost::cv_status::no_timeout==st);
+ BOOST_TEST(st != boost::cv_status::timeout);
+ BOOST_TEST(boost::cv_status::timeout!=st);
+ }
+ {
+ boost::cv_status st;
+ st = boost::cv_status::timeout;
+ BOOST_TEST(st == boost::cv_status::timeout);
+ BOOST_TEST(boost::cv_status::timeout==st);
+ BOOST_TEST(st != boost::cv_status::no_timeout);
+ BOOST_TEST(boost::cv_status::no_timeout!=st);
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/futures/async/async_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/futures/async/async_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/future.hpp>
+
+// template <class F, class... Args>
+// future<typename result_of<F(Args...)>::type>
+// async(F&& f, Args&&... args);
+
+// template <class F, class... Args>
+// future<typename result_of<F(Args...)>::type>
+// async(launch policy, F&& f, Args&&... args);
+
+
+#include <boost/thread/future.hpp>
+#include <memory>
+#include <boost/detail/lightweight_test.hpp>
+
+typedef boost::chrono::high_resolution_clock Clock;
+typedef boost::chrono::milliseconds ms;
+
+int f0()
+{
+ boost::this_thread::sleep_for(ms(200));
+ return 3;
+}
+
+int i = 0;
+
+int& f1()
+{
+ boost::this_thread::sleep_for(ms(200));
+ return i;
+}
+
+void f2()
+{
+ boost::this_thread::sleep_for(ms(200));
+}
+
+boost::unique_ptr<int> f3(int i)
+{
+ boost::this_thread::sleep_for(ms(200));
+ return boost::unique_ptr<int>(new int(i));
+}
+
+boost::unique_ptr<int> f4(boost::unique_ptr<int>&& p)
+{
+ boost::this_thread::sleep_for(ms(200));
+ return boost::move(p);
+}
+
+int main()
+{
+ {
+ boost::future<int> f = boost::async(f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<int> f = boost::async(boost::launch::async, f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<int> f = boost::async(boost::launch::any, f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<int> f = boost::async(boost::launch::deferred, f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 > ms(100));
+ }
+
+ {
+ boost::future<int&> f = boost::async(f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<int&> f = boost::async(boost::launch::async, f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<int&> f = boost::async(boost::launch::any, f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<int&> f = boost::async(boost::launch::deferred, f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 > ms(100));
+ }
+
+ {
+ boost::future<void> f = boost::async(f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<void> f = boost::async(boost::launch::async, f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<void> f = boost::async(boost::launch::any, f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ {
+ boost::future<void> f = boost::async(boost::launch::deferred, f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 > ms(100));
+ }
+
+ {
+ boost::future<boost::unique_ptr<int>> f = boost::async(f3, 3);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+
+ {
+ boost::future<boost::unique_ptr<int>> f = boost::async(f4, boost::unique_ptr<int>(new int(3)));
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(100));
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, adopt_lock_t);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ boost::mutex m;
+ m.lock();
+ boost::unique_lock<boost::mutex> lk(m, boost::adopt_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m0;
+boost::mutex m1;
+
+int main()
+{
+ boost::unique_lock<boost::mutex> lk0(m0);
+ boost::unique_lock<boost::mutex> lk1(m1);
+ lk1 = lk0;
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m0;
+boost::mutex m1;
+
+int main()
+{
+ boost::unique_lock<boost::mutex> lk0(m0);
+ boost::unique_lock<boost::mutex> lk1 = lk0;
+ BOOST_TEST(lk1.mutex() == &m1);
+ BOOST_TEST(lk1.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::unique_lock<boost::mutex> ul;
+ BOOST_TEST(!ul.owns_lock());
+ BOOST_TEST(ul.mutex() == 0);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, adopt_lock_t);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::mutex m;
+ m.lock();
+ boost::unique_lock<boost::mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+// unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::timed_mutex m;
+
+typedef boost::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ boost::unique_lock<boost::timed_mutex> lk(m, ms(300));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ boost::unique_lock<boost::timed_mutex> lk(m, ms(250));
+ BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ boost::thread t(f1);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ boost::thread t(f2);
+ boost::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m0;
+boost::mutex m1;
+
+int main()
+{
+ boost::unique_lock<boost::mutex> lk0(m0);
+ boost::unique_lock<boost::mutex> lk1(m1);
+ lk1 = boost::move(lk0);
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+
+ return boost::report_errors();
+
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+int main()
+{
+ boost::unique_lock<boost::mutex> lk0(m);
+ boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// explicit unique_lock(Mutex& m);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ boost::unique_lock<boost::mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(2500000)); // within 2.5ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Clock, class Duration>
+// unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::timed_mutex m;
+
+typedef boost::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ boost::unique_lock<boost::timed_mutex> lk(m, Clock::now() + ms(300));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ boost::unique_lock<boost::timed_mutex> lk(m, Clock::now() + ms(250));
+ BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ boost::thread t(f1);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ boost::thread t(f2);
+ boost::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, try_to_lock_t);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ {
+ boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ while (true)
+ {
+ boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
+ if (lk.owns_lock()) break;
+ }
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// void lock();
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+boost::mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ boost::unique_lock < boost::mutex > lk(m, boost::defer_lock);
+ time_point t0 = Clock::now();
+ lk.lock();
+ time_point t1 = Clock::now();
+ BOOST_TEST(lk.owns_lock() == true);
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(2500000)); // within 2.5ms
+ try
+ {
+ lk.lock();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
+ }
+ lk.unlock();
+ lk.release();
+ try
+ {
+ lk.lock();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
+ }
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/locks.hpp>
+//#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_for_called = false;
+
+typedef boost::chrono::milliseconds ms;
+
+struct mutex
+{
+ template <class Rep, class Period>
+ bool try_lock_for(const boost::chrono::duration<Rep, Period>& rel_time)
+ {
+ BOOST_TEST(rel_time == ms(5));
+ try_lock_for_called = !try_lock_for_called;
+ return try_lock_for_called;
+ }
+ void unlock()
+ {
+ }
+};
+
+mutex m;
+
+int main()
+{
+ boost::unique_lock<mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(lk.try_lock_for(ms(5)) == true);
+ BOOST_TEST(try_lock_for_called == true);
+ BOOST_TEST(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock_for(ms(5));
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
+ }
+ lk.unlock();
+ BOOST_TEST(lk.try_lock_for(ms(5)) == false);
+ BOOST_TEST(try_lock_for_called == false);
+ BOOST_TEST(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock_for(ms(5));
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/locks.hpp>
+//#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_called = false;
+
+struct mutex
+{
+ bool try_lock()
+ {
+ try_lock_called = !try_lock_called;
+ return try_lock_called;
+ }
+ void unlock()
+ {
+ }
+};
+
+mutex m;
+
+int main()
+{
+ boost::unique_lock<mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(lk.try_lock() == true);
+ BOOST_TEST(try_lock_called == true);
+ BOOST_TEST(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
+ }
+ lk.unlock();
+ BOOST_TEST(lk.try_lock() == false);
+ BOOST_TEST(try_lock_called == false);
+ BOOST_TEST(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+ template <class Clock, class Duration>
+ bool try_lock_until(const boost::chrono::time_point<Clock, Duration>& abs_time)
+ {
+ typedef boost::chrono::milliseconds ms;
+ BOOST_TEST(Clock::now() - abs_time < ms(5));
+ try_lock_until_called = !try_lock_until_called;
+ return try_lock_until_called;
+ }
+ void unlock()
+ {
+ }
+};
+
+mutex m;
+
+int main()
+{
+ typedef boost::chrono::steady_clock Clock;
+ boost::unique_lock<mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(lk.try_lock_until(Clock::now()) == true);
+ BOOST_TEST(try_lock_until_called == true);
+ BOOST_TEST(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock_until(Clock::now());
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
+ }
+ lk.unlock();
+ BOOST_TEST(lk.try_lock_until(Clock::now()) == false);
+ BOOST_TEST(try_lock_until_called == false);
+ BOOST_TEST(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock_until(Clock::now());
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
+ }
+ return boost::report_errors();
+}

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/locks.hpp>
+//#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool unlock_called = false;
+
+struct mutex
+{
+ void lock()
+ {
+ }
+ void unlock()
+ {
+ unlock_called = true;
+ }
+};
+
+mutex m;
+
+int main()
+{
+ boost::unique_lock<mutex> lk(m);
+ lk.unlock();
+ BOOST_TEST(unlock_called == true);
+ BOOST_TEST(lk.owns_lock() == false);
+ try
+ {
+ lk.unlock();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
+ }
+ lk.release();
+ try
+ {
+ lk.unlock();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// void swap(unique_lock& u);
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct mutex
+{
+ void lock()
+ {
+ }
+ void unlock()
+ {
+ }
+};
+
+mutex m;
+
+int main()
+{
+ boost::unique_lock<mutex> lk1(m);
+ boost::unique_lock<mutex> lk2;
+ lk1.swap(lk2);
+ BOOST_TEST(lk1.mutex() == 0);
+ BOOST_TEST(lk1.owns_lock() == false);
+ BOOST_TEST(lk2.mutex() == &m);
+ BOOST_TEST(lk2.owns_lock() == true);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex>
+// void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct mutex
+{
+ void lock()
+ {
+ }
+ void unlock()
+ {
+ }
+};
+
+mutex m;
+
+int main()
+{
+ boost::unique_lock<mutex> lk1(m);
+ boost::unique_lock<mutex> lk2;
+ swap(lk1, lk2);
+ BOOST_TEST(lk1.mutex() == 0);
+ BOOST_TEST(lk1.owns_lock() == false);
+ BOOST_TEST(lk2.mutex() == &m);
+ BOOST_TEST(lk2.owns_lock() == true);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// void Mutex* release();
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct mutex
+{
+ static int lock_count;
+ static int unlock_count;
+ void lock()
+ {
+ ++lock_count;
+ }
+ void unlock()
+ {
+ ++unlock_count;
+ }
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+int main()
+{
+ boost::unique_lock<mutex> lk(m);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(mutex::lock_count == 1);
+ BOOST_TEST(mutex::unlock_count == 0);
+ BOOST_TEST(lk.release() == &m);
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(mutex::lock_count == 1);
+ BOOST_TEST(mutex::unlock_count == 0);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// Mutex *mutex() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+int main()
+{
+ boost::unique_lock<boost::mutex> lk0;
+ BOOST_TEST(lk0.mutex() == 0);
+ boost::unique_lock<boost::mutex> lk1(m);
+ BOOST_TEST(lk1.mutex() == &m);
+ lk1.unlock();
+ BOOST_TEST(lk1.mutex() == &m);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// explicit operator bool() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+int main()
+{
+ boost::unique_lock < boost::mutex > lk0;
+ BOOST_TEST(bool(lk0) == false);
+ boost::unique_lock < boost::mutex > lk1(m);
+ BOOST_TEST(bool(lk1) == true);
+ lk1.unlock();
+ BOOST_TEST(bool(lk1) == false);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// bool owns_lock() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+int main()
+{
+ boost::unique_lock<boost::mutex> lk0;
+ BOOST_TEST(lk0.owns_lock() == false);
+ boost::unique_lock<boost::mutex> lk1(m);
+ BOOST_TEST(lk1.owns_lock() == true);
+ lk1.unlock();
+ BOOST_TEST(lk1.owns_lock() == false);
+
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// <mutex>
+
+// struct defer_lock_t {};
+// struct try_to_lock_t {};
+// struct adopt_lock_t {};
+//
+// constexpr defer_lock_t defer_lock{};
+// constexpr try_to_lock_t try_to_lock{};
+// constexpr adopt_lock_t adopt_lock{};
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ typedef boost::defer_lock_t T1;
+ typedef boost::try_to_lock_t T2;
+ typedef boost::adopt_lock_t T3;
+
+ T1 t1 = boost::defer_lock;
+ T2 t2 = boost::try_to_lock;
+ T3 t3 = boost::adopt_lock;
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/mutex/assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/mutex/assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// class mutex;
+
+// mutex& operator=(const mutex&) = delete;
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::mutex m0;
+ boost::mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/mutex/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/mutex/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// class mutex;
+
+// mutex(const mutex&) = delete;
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::mutex m0;
+ boost::mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/mutex/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/mutex/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// class mutex;
+
+// mutex();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::mutex m0;
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/mutex/lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/mutex/lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// class mutex;
+
+// void lock();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(2500000)); // within 2.5ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/mutex/native_handle_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/mutex/native_handle_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::mutex m;
+ boost::mutex::native_handle_type h = m.native_handle();
+ BOOST_TEST(h);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/mutex/try_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/mutex/try_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/mutex.hpp>
+
+// class mutex;
+
+// bool try_lock();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ while (!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_mutex;
+
+// recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_mutex m0;
+ boost::recursive_mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_mutex;
+
+// recursive_mutex(const recursive_mutex&) = delete;
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_mutex m0;
+ boost::recursive_mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_mutex;
+
+// recursive_mutex();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_mutex m0;
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_mutex;
+
+// void lock();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::recursive_mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.lock();
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(2500000)); // within 2.5ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/native_handle_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/native_handle_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_mutex;
+
+// typedef pthread_recursive_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_mutex m;
+ boost::recursive_mutex::native_handle_type h = m.native_handle();
+ BOOST_TEST(h);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_mutex;
+
+// bool try_lock();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::recursive_mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ while (!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ BOOST_TEST(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_timed_mutex m0;
+ boost::recursive_timed_mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_timed_mutex m0;
+ boost::recursive_timed_mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_timed_mutex m0;
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// void lock();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::recursive_timed_mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.lock();
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(2500000)); // within 2.5ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/native_handle_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/native_handle_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// typedef pthread_recursive_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::recursive_timed_mutex m;
+ boost::recursive_timed_mutex::native_handle_type h = m.native_handle();
+ BOOST_TEST(h);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_for_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_for_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::recursive_timed_mutex m;
+
+typedef boost::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_for(ms(300)) == true);
+ time_point t1 = Clock::now();
+ BOOST_TEST(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_for(ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ boost::thread t(f1);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ boost::thread t(f2);
+ boost::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex.hpp>
+
+// class recursive_timed_mutex;
+
+// bool try_lock();
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::recursive_timed_mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ while (!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ BOOST_TEST(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_until_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_until_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/recursive_mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::recursive_timed_mutex m;
+
+typedef boost::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_until(Clock::now() + ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_until(Clock::now() + ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ boost::thread t(f1);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ boost::thread t(f2);
+ boost::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// timed_mutex& operator=(const timed_mutex&) = delete;
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::timed_mutex m0;
+ boost::timed_mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// timed_mutex(const timed_mutex&) = delete;
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::timed_mutex m0;
+ boost::timed_mutex m1(m0);
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// timed_mutex();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::timed_mutex m0;
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// void lock();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::timed_mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(2500000)); // within 2.5ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/native_handle_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/native_handle_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// typedef pthread_timed_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ boost::timed_mutex m;
+ boost::timed_mutex::native_handle_type h = m.native_handle();
+ BOOST_TEST(h);
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::timed_mutex m;
+
+typedef boost::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_for(ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_for(ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ boost::thread t(f1);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ boost::thread t(f2);
+ boost::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// bool try_lock();
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::timed_mutex m;
+
+typedef boost::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ BOOST_TEST(!m.try_lock());
+ while (!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/timed_mutex.hpp>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::timed_mutex m;
+
+typedef boost::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_until(Clock::now() + ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ BOOST_TEST(m.try_lock_until(Clock::now() + ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(5000000)); // within 5ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ boost::thread t(f1);
+ boost::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ boost::thread t(f2);
+ boost::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/this_thread/get_id/get_id_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/this_thread/get_id/get_id_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// thread::id this_thread::get_id();
+
+#include <boost/thread/thread.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::thread::id id = boost::this_thread::get_id();
+ BOOST_TEST(id != boost::thread::id());
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// thread::id this_thread::get_id();
+
+#include <boost/thread/thread.hpp>
+#include <cstdlib>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef Clock::time_point time_point;
+ typedef Clock::duration duration;
+ boost::chrono::milliseconds ms(500);
+ time_point t0 = Clock::now();
+ boost::this_thread::sleep_for(ms);
+ time_point t1 = Clock::now();
+ boost::chrono::nanoseconds ns = (t1 - t0) - ms;
+ boost::chrono::nanoseconds err = ms / 100;
+ // The time slept is within 1% of 500ms
+ BOOST_TEST(std::abs(ns.count()) < err.count());
+
+}
+

Added: trunk/libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// thread::id this_thread::get_id();
+
+#include <boost/thread/thread.hpp>
+#include <cstdlib>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef Clock::time_point time_point;
+ typedef Clock::duration duration;
+ boost::chrono::milliseconds ms(500);
+ time_point t0 = Clock::now();
+ boost::this_thread::sleep_until(t0 + ms);
+ time_point t1 = Clock::now();
+ boost::chrono::nanoseconds ns = (t1 - t0) - ms;
+ boost::chrono::nanoseconds err = ms / 100;
+ // The time slept is within 1% of 500ms
+ BOOST_TEST(std::abs(ns.count()) < err.count());
+
+}
+

Added: trunk/libs/thread/test/threads/thread/assign/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/assign/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ boost::thread t1;
+ t1 = t0;
+ }
+}
+

Added: trunk/libs/thread/test/threads/thread/assign/move_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/assign/move_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ BOOST_TEST(i == 5);
+ BOOST_TEST(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ {
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t0(G(), 5, 5.5);
+ boost::thread::id id = t0.get_id();
+ boost::thread t1;
+ t1 = boost::move(t0);
+ BOOST_TEST(t1.get_id() == id);
+ BOOST_TEST(t0.get_id() == boost::thread::id());
+ t1.join();
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(G::op_run);
+ }
+ {
+ boost::thread t0(G(), 5, 5.5);
+ boost::thread::id id = t0.get_id();
+ boost::thread t1;
+ t0 = boost::move(t1);
+ BOOST_TEST(false);
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/constr/F_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/F_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// template <class F, class ...Args> thread(F f, Args... args);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+unsigned throw_one = 0xFFFF;
+
+void* operator new(std::size_t s) throw (std::bad_alloc)
+{
+ if (throw_one == 0) throw std::bad_alloc();
+ --throw_one;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw ()
+{
+ std::free(p);
+}
+
+bool f_run = false;
+
+void f()
+{
+ f_run = true;
+}
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive >= 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive >= 1);
+ BOOST_TEST(i == 5);
+ BOOST_TEST(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+
+int main()
+{
+ {
+ boost::thread t(f);
+ t.join();
+ BOOST_TEST(f_run == true);
+ }
+ f_run = false;
+ {
+ try
+ {
+ throw_one = 0;
+ boost::thread t(f);
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ throw_one = 0xFFFF;
+ BOOST_TEST(!f_run);
+ }
+ }
+ {
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t( (G()));
+ t.join();
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(G::op_run);
+ }
+ G::op_run = false;
+ {
+ try
+ {
+ throw_one = 0;
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t( (G()));
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ throw_one = 0xFFFF;
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ }
+ }
+ {
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t(G(), 5, 5.5);
+ t.join();
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(G::op_run);
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// template <class F, class ...Args> thread(F&& f, Args&&... args);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+public:
+ MoveOnly()
+ {
+ }
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ MoveOnly(MoveOnly&&)
+ {}
+ void operator()(MoveOnly&&)
+ {
+ }
+#else
+ MoveOnly(detail::thread_move_t<MoveOnly>)
+ {}
+ void operator()(detail::thread_move_t<MoveOnly>)
+ {
+ }
+#endif
+
+};
+
+int main()
+{
+ {
+ boost::thread t = boost::thread(MoveOnly(), MoveOnly());
+ t.join();
+ }
+ return boost::report_errors();
+}

Added: trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/Frvalue_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// template <class F, class ...Args> thread(F&& f, Args&&... args);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+public:
+ MoveOnly()
+ {
+ }
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ MoveOnly(MoveOnly&&)
+ {}
+#else
+ MoveOnly(detail::thread_move_t<MoveOnly>)
+ {}
+#endif
+
+ void operator()()
+ {
+ }
+};
+
+int main()
+{
+ {
+ boost::thread t = boost::thread(MoveOnly());
+ t.join();
+ }
+ return boost::report_errors();
+}

Added: trunk/libs/thread/test/threads/thread/constr/copy_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/copy_fail.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// thread(const thread&) = delete;
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ BOOST_TEST(i == 5);
+ BOOST_TEST(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t0(G(), 5, 5.5);
+ boost::thread::id id = t0.get_id();
+ boost::thread t1( (t0));
+ BOOST_TEST(t1.get_id() == id);
+ BOOST_TEST(t0.get_id() == boost::thread::id());
+ t1.join();
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(G::op_run);
+ }
+}

Added: trunk/libs/thread/test/threads/thread/constr/default_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/default_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// thread();
+
+#include <boost/thread/thread.hpp>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::thread t;
+ BOOST_TEST(t.get_id() == boost::thread::id());
+ return boost::report_errors();
+}

Added: trunk/libs/thread/test/threads/thread/constr/move_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/move_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// thread(thread&& t);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ BOOST_TEST(i == 5);
+ BOOST_TEST(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t0(G(), 5, 5.5);
+ boost::thread::id id = t0.get_id();
+ boost::thread t1((boost::move(t0)));
+ BOOST_TEST(t1.get_id() == id);
+ BOOST_TEST(t0.get_id() == boost::thread::id());
+ t1.join();
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(G::op_run);
+ }
+ return boost::report_errors();
+}

Added: trunk/libs/thread/test/threads/thread/destr/dtor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/destr/dtor_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// ~thread();
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ {
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(!G::op_run);
+ boost::thread t( (G()));
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(250));
+ //boost::this_thread::sleep(boost::posix_time::milliseconds(250));
+
+ }
+ BOOST_TEST(false);
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/id/hash_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/id/hash_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ boost::thread::id id1;
+ boost::thread::id id2 = boost::this_thread::get_id();
+ typedef boost::hash<boost::thread::id> H;
+ H h;
+ BOOST_TEST(h(id1) != h(id2));
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/members/detach_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/members/detach_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// void detach();
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ BOOST_TEST(t0.joinable());
+ t0.detach();
+ BOOST_TEST(!t0.joinable());
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(250));
+ BOOST_TEST(G::op_run);
+ BOOST_TEST(G::n_alive == 0);
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/members/get_id_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/members/get_id_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// id get_id() const;
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ boost::thread::id id0 = t0.get_id();
+ boost::thread t1;
+ boost::thread::id id1 = t1.get_id();
+ BOOST_TEST(t0.get_id() != id1);
+ BOOST_TEST(t1.get_id() == boost::thread::id());
+ t0.join();
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/members/join_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/members/join_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,130 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// void join();
+
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/locks.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <iostream>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+boost::thread* resource_deadlock_would_occur_th;
+boost::mutex resource_deadlock_would_occur_mtx;
+void resource_deadlock_would_occur_tester()
+{
+ try
+ {
+ boost::unique_lock<boost::mutex> lk(resource_deadlock_would_occur_mtx);
+
+ resource_deadlock_would_occur_th->join();
+ BOOST_TEST(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
+ }
+}
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ BOOST_TEST(t0.joinable());
+ t0.join();
+ BOOST_TEST(!t0.joinable());
+ }
+ {
+ boost::unique_lock<boost::mutex> lk(resource_deadlock_would_occur_mtx);
+ boost::thread t0( resource_deadlock_would_occur_tester );
+ resource_deadlock_would_occur_th = &t0;
+ BOOST_TEST(t0.joinable());
+ lk.unlock();
+ t0.join();
+ BOOST_TEST(!t0.joinable());
+ }
+
+// {
+// boost::thread t0( (G()));
+// t0.detach();
+// try
+// {
+// t0.join();
+// BOOST_TEST(false);
+// }
+// catch (boost::system::system_error& e)
+// {
+// BOOST_TEST(e.code().value() == boost::system::errc::no_such_process);
+// }
+// }
+// {
+// boost::thread t0( (G()));
+// BOOST_TEST(t0.joinable());
+// t0.join();
+// BOOST_TEST(!t0.joinable());
+// try
+// {
+// t0.join();
+// BOOST_TEST(false);
+// }
+// catch (boost::system::system_error& e)
+// {
+// BOOST_TEST(e.code().value() == boost::system::errc::invalid_argument);
+// }
+//
+// }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/members/joinable_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/members/joinable_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// bool joinable() const;
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ BOOST_TEST(t0.joinable());
+ t0.join();
+ BOOST_TEST(!t0.joinable());
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/members/native_handle_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/members/native_handle_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ boost::thread::native_handle_type hdl = t0.native_handle();
+ t0.join();
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/members/swap_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/members/swap_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <boost/thread/thread.hpp>
+#include <cstdlib>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ boost::thread::id id0 = t0.get_id();
+ boost::thread t1;
+ boost::thread::id id1 = t1.get_id();
+ t0.swap(t1);
+ BOOST_TEST(t0.get_id() == id1);
+ BOOST_TEST(t1.get_id() == id0);
+ t1.join();
+ }
+}
+

Added: trunk/libs/thread/test/threads/thread/non_members/swap_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/non_members/swap_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// void swap(thread& x, thread& y);
+
+#include <boost/thread/thread.hpp>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/detail/lightweight_test.hpp>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()()
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive == 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ boost::thread t0( (G()));
+ boost::thread::id id0 = t0.get_id();
+ boost::thread t1;
+ boost::thread::id id1 = t1.get_id();
+ swap(t0, t1);
+ BOOST_TEST(t0.get_id() == id1);
+ BOOST_TEST(t1.get_id() == id0);
+ t1.join();
+ }
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/threads/thread/static/hardware_concurrency_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/static/hardware_concurrency_pass.cpp 2012-01-03 16:23:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/thread.hpp>
+
+// class thread
+
+// static unsigned hardware_concurrency();
+
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_TEST(boost::thread::hardware_concurrency() > 0);
+ return boost::report_errors();
+}
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk