summaryrefslogtreecommitdiff
path: root/libs/thread/test/sync/mutual_exclusion/locks
diff options
context:
space:
mode:
Diffstat (limited to 'libs/thread/test/sync/mutual_exclusion/locks')
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/lock_guard/adopt_lock_pass.cpp72
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp45
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp44
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/lock_guard/default_pass.cpp72
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/lock_guard/types_pass.cpp39
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp41
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp40
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/reverse_lock/types_pass.cpp33
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/reverse_lock/unique_lock_ctor_pass.cpp52
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/adopt_lock_pass.cpp37
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp49
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp48
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/default_pass.cpp33
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/defer_lock_pass.cpp35
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/duration_pass.cpp79
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp82
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp47
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_unique_lock_pass.cpp65
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_upgrade_lock_pass.cpp64
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/mutex_pass.cpp76
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/time_point_pass.cpp77
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/try_to_lock_pass.cpp102
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/lock_pass.cpp114
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_for_pass.cpp78
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_pass.cpp74
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_until_pass.cpp76
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/unlock_pass.cpp69
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/member_swap_pass.cpp48
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/non_member_swap_pass.cpp47
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp58
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/mutex_pass.cpp38
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/op_bool_pass.cpp38
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/owns_lock_pass.cpp39
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock/types_pass.cpp40
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/adopt_lock_pass.cpp75
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp45
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp44
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/default_pass.cpp74
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/types_pass.cpp40
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp36
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp49
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp48
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp33
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp35
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp85
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp52
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp63
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_for_pass.cpp69
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_try_pass.cpp66
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_until_pass.cpp69
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_for_pass.cpp67
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_pass.cpp63
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_try_pass.cpp64
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_until_pass.cpp67
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp78
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp84
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp104
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp115
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp85
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp73
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp84
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp69
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp48
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp47
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp58
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp38
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp48
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp47
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp39
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp39
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/adopt_lock_pass.cpp37
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp49
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp48
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/default_pass.cpp33
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/defer_lock_pass.cpp35
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/duration_pass.cpp80
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_assign_pass.cpp66
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_pass.cpp46
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_for_pass.cpp69
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_try_pass.cpp66
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_until_pass.cpp69
-rw-r--r--libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_unique_lock_pass.cpp46
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/mutex_pass.cpp76
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/time_point_pass.cpp79
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/try_to_lock_pass.cpp103
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/lock_pass.cpp114
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_for_pass.cpp78
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_pass.cpp74
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_until_pass.cpp76
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/unlock_pass.cpp69
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/member_swap_pass.cpp48
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp47
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/release_pass.cpp58
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/mutex_pass.cpp38
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/op_bool_pass.cpp38
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/owns_lock_pass.cpp39
-rwxr-xr-xlibs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/types_pass.cpp40
97 files changed, 5772 insertions, 0 deletions
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/adopt_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/adopt_lock_pass.cpp
new file mode 100755
index 0000000000..1f6fde9842
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/adopt_lock_pass.cpp
@@ -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) 2012 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 lock_guard;
+
+// lock_guard(mutex_type& m, adopt_lock_t);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#ifdef BOOST_THREAD_USES_CHRONO
+typedef boost::chrono::high_resolution_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+#endif
+boost::mutex m;
+
+void f()
+{
+#ifdef BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ m.lock();
+ boost::lock_guard<boost::mutex> lg(m, boost::adopt_lock);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ m.lock();
+ boost::lock_guard<boost::mutex> lg(m, boost::adopt_lock);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#ifdef BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp
new file mode 100755
index 0000000000..5e90b4b3e8
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 lock_guard;
+
+// lock_guard& operator=(lock_guard 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::lock_guard<boost::mutex> lk0(m0);
+ boost::lock_guard<boost::mutex> lk1(m1);
+ lk1 = lk0;
+
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp
new file mode 100755
index 0000000000..81b2238171
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 lock_guard;
+
+// lock_guard(lock_guard 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::lock_guard<boost::mutex> lk0(m0);
+ boost::lock_guard<boost::mutex> lk1 = lk0;
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/default_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/default_pass.cpp
new file mode 100755
index 0000000000..f57849646b
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/default_pass.cpp
@@ -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/locks.hpp>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(lock_guard const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#ifdef BOOST_THREAD_USES_CHRONO
+typedef boost::chrono::high_resolution_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+#endif
+
+boost::mutex m;
+
+void f()
+{
+#ifdef BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ boost::lock_guard<boost::mutex> lg(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ boost::lock_guard<boost::mutex> lg(m);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#ifdef BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/types_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/types_pass.cpp
new file mode 100755
index 0000000000..161d69d5f1
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/types_pass.cpp
@@ -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) 2012 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>
+
+// template <class Mutex>
+// class lock_guard
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+
+#include <boost/thread/mutex.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<boost::lock_guard<boost::mutex>::mutex_type,
+ boost::mutex>::value), "");
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp
new file mode 100755
index 0000000000..77808fc028
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2012 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 reverse_lock;
+
+// reverse_lock& operator=(reverse_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/reverse_lock.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ boost::mutex m0;
+ boost::mutex m1;
+ boost::unique_lock<boost::mutex> lk0(m0);
+ boost::unique_lock<boost::mutex> lk1(m1);
+ {
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0);
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lk1);
+ lg1 = lg0;
+ }
+
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp
new file mode 100755
index 0000000000..a5e2348457
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp
@@ -0,0 +1,40 @@
+// Copyright (C) 2012 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 reverse_lock;
+
+// reverse_lock(reverse_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/reverse_lock.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m0;
+boost::mutex m1;
+
+int main()
+{
+ boost::mutex m0;
+ boost::unique_lock<boost::mutex> lk0(m0);
+ {
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0);
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lg0);
+ }
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/types_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/types_pass.cpp
new file mode 100755
index 0000000000..30dafa1fa4
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/types_pass.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2012 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>
+
+// template <class Mutex>
+// class unlock_guard
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/reverse_lock.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<boost::reverse_lock<boost::unique_lock<boost::mutex> >::mutex_type,
+ boost::mutex>::value), "");
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/unique_lock_ctor_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/unique_lock_ctor_pass.cpp
new file mode 100755
index 0000000000..99b4f00c33
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/reverse_lock/unique_lock_ctor_pass.cpp
@@ -0,0 +1,52 @@
+// Copyright (C) 2012 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 unlock_guard;
+
+// unlock_guard(unlock_guard const&) = delete;
+
+#include <boost/thread/reverse_lock.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ {
+ boost::mutex m;
+ boost::unique_lock<boost::mutex> lk(m);
+ BOOST_TEST(lk.owns_lock());
+ BOOST_TEST(lk.mutex()==&m);
+
+ {
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > lg(lk);
+ BOOST_TEST(!lk.owns_lock());
+ BOOST_TEST(lk.mutex()==0);
+ }
+ BOOST_TEST(lk.owns_lock());
+ BOOST_TEST(lk.mutex()==&m);
+ }
+
+ {
+ boost::mutex m;
+ boost::unique_lock<boost::mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(! lk.owns_lock());
+ BOOST_TEST(lk.mutex()==&m);
+ {
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > lg(lk);
+ BOOST_TEST(!lk.owns_lock());
+ BOOST_TEST(lk.mutex()==0);
+ }
+ BOOST_TEST(lk.owns_lock());
+ BOOST_TEST(lk.mutex()==&m);
+ }
+
+
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/adopt_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/adopt_lock_pass.cpp
new file mode 100755
index 0000000000..732ad6325a
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/adopt_lock_pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// shared_lock(mutex_type& m, adopt_lock_t);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ boost::shared_mutex m;
+ m.lock();
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::adopt_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp
new file mode 100755
index 0000000000..55ef440c80
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// shared_lock& operator=(shared_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ boost::shared_lock<boost::shared_mutex> lk0(m0);
+ boost::shared_lock<boost::shared_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);
+
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp
new file mode 100755
index 0000000000..1756a63342
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp
@@ -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 shared_lock;
+
+// shared_lock(shared_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ boost::shared_lock<boost::shared_mutex> lk0(m0);
+ boost::shared_lock<boost::shared_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);
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/default_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/default_pass.cpp
new file mode 100755
index 0000000000..e7b8127711
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/default_pass.cpp
@@ -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 shared_lock;
+
+// shared_lock(shared_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::shared_lock<boost::shared_mutex> ul;
+ BOOST_TEST(!ul.owns_lock());
+ BOOST_TEST(ul.mutex() == 0);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/defer_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/defer_lock_pass.cpp
new file mode 100755
index 0000000000..caeec9c2db
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/defer_lock_pass.cpp
@@ -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 shared_lock;
+
+// shared_lock(mutex_type& m, adopt_lock_t);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::shared_mutex m;
+ m.lock();
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/duration_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/duration_pass.cpp
new file mode 100755
index 0000000000..d08304f762
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/duration_pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// template <class Rep, class Period>
+// shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/chrono/chrono_io.hpp>
+
+boost::shared_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();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::shared_lock<boost::shared_mutex> lk(m, ms(300)+ms(1000));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ boost::shared_lock<boost::shared_mutex> lk(m, ms(250));
+ BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::this_thread::sleep_for(ms(300)+ms(1000));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp
new file mode 100755
index 0000000000..b3348f706b
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/shared_mutex.hpp>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m0);
+ boost::shared_lock<boost::shared_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);
+ }
+ {
+
+ boost::shared_lock<boost::shared_mutex> lk1;
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(m0));
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex> lk0(m0);
+ boost::shared_lock<boost::shared_mutex> lk1(m1);
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(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);
+ }
+ {
+
+ boost::shared_lock<boost::shared_mutex> lk1;
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::unique_lock<boost::shared_mutex>(m0)));
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk0(m0);
+ boost::shared_lock<boost::shared_mutex> lk1(m1);
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(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);
+ }
+ {
+
+ boost::shared_lock<boost::shared_mutex> lk1;
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::upgrade_lock<boost::shared_mutex>(m0)));
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ }
+ return boost::report_errors();
+
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp
new file mode 100755
index 0000000000..173f6b5c99
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp
@@ -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> class shared_lock;
+
+// shared_lock& operator=(shared_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::shared_lock<boost::shared_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);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(m))));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_unique_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_unique_lock_pass.cpp
new file mode 100644
index 0000000000..90325ed6ad
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_unique_lock_pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// shared_lock& operator=(shared_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+
+ {
+ boost::unique_lock<boost::shared_mutex> lk0(m);
+ boost::shared_lock<boost::shared_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);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk( (boost::unique_lock<boost::shared_mutex>(m)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_upgrade_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_upgrade_lock_pass.cpp
new file mode 100644
index 0000000000..b98183e233
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_upgrade_lock_pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// shared_lock& operator=(shared_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk0(m);
+ boost::shared_lock<boost::shared_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);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk( (boost::upgrade_lock<boost::shared_mutex>(m)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/mutex_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/mutex_pass.cpp
new file mode 100755
index 0000000000..0a0d191a82
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/mutex_pass.cpp
@@ -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 shared_lock;
+
+// explicit shared_lock(Mutex& m);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ boost::shared_lock<boost::shared_mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(2000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ boost::shared_lock<boost::shared_mutex> ul(m);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/time_point_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/time_point_pass.cpp
new file mode 100755
index 0000000000..9308b8550c
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/time_point_pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// template <class Clock, class Duration>
+// shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_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();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::shared_lock<boost::shared_mutex> lk(m, Clock::now() + ms(300)+ms(1000));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ boost::shared_lock<boost::shared_mutex> lk(m, Clock::now() + ms(250));
+ BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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)+ms(1000));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/try_to_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/try_to_lock_pass.cpp
new file mode 100755
index 0000000000..9f4251e9b6
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/try_to_lock_pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// shared_lock(mutex_type& m, try_to_lock_t);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ {
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ while (true)
+ {
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ if (lk.owns_lock()) break;
+ }
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+#else
+// time_point t0 = Clock::now();
+// {
+// boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+// BOOST_TEST(lk.owns_lock() == false);
+// }
+// {
+// boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+// BOOST_TEST(lk.owns_lock() == false);
+// }
+// {
+// boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+// BOOST_TEST(lk.owns_lock() == false);
+// }
+ while (true)
+ {
+ boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ if (lk.owns_lock()) break;
+ }
+ //time_point t1 = Clock::now();
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/lock_pass.cpp
new file mode 100755
index 0000000000..3ef6f7c2c1
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/lock_pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 shared_lock;
+
+// void lock();
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+boost::shared_mutex m;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::shared_lock < boost::shared_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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // 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);
+ }
+#else
+ boost::shared_lock < boost::shared_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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // 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);
+ }
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_for_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_for_pass.cpp
new file mode 100755
index 0000000000..027cf64d0a
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_for_pass.cpp
@@ -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 shared_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_for_called = false;
+
+typedef boost::chrono::milliseconds ms;
+
+struct shared_mutex
+{
+ template <class Rep, class Period>
+ bool try_lock_shared_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_shared()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_pass.cpp
new file mode 100755
index 0000000000..5ba50cc3e5
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_pass.cpp
@@ -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 shared_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_called = false;
+
+struct shared_mutex
+{
+ bool try_lock_shared()
+ {
+ try_lock_called = !try_lock_called;
+ return try_lock_called;
+ }
+ void unlock_shared()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_until_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_until_pass.cpp
new file mode 100755
index 0000000000..77dd7dc8cc
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/try_lock_until_pass.cpp
@@ -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 shared_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_until_called = false;
+
+struct shared_mutex
+{
+ template <class Clock, class Duration>
+ bool try_lock_shared_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_shared()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ typedef boost::chrono::steady_clock Clock;
+ boost::shared_lock<shared_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();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/unlock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/unlock_pass.cpp
new file mode 100755
index 0000000000..1eaba78c93
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/unlock_pass.cpp
@@ -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 shared_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool unlock_called = false;
+
+struct shared_mutex
+{
+ void lock_shared()
+ {
+ }
+ void unlock_shared()
+ {
+ unlock_called = true;
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/member_swap_pass.cpp
new file mode 100755
index 0000000000..949166f58b
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/member_swap_pass.cpp
@@ -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 shared_lock;
+
+// void swap(shared_lock& u);
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct shared_mutex
+{
+ void lock_shared()
+ {
+ }
+ void unlock_shared()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<shared_mutex> lk1(m);
+ boost::shared_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/non_member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/non_member_swap_pass.cpp
new file mode 100755
index 0000000000..766d63ec31
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/non_member_swap_pass.cpp
@@ -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(shared_lock<Mutex>& x, shared_lock<Mutex>& y);
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct shared_mutex
+{
+ void lock_shared()
+ {
+ }
+ void unlock_shared()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<shared_mutex> lk1(m);
+ boost::shared_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp
new file mode 100755
index 0000000000..5a88c1f296
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp
@@ -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 shared_lock;
+
+// void Mutex* release();
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct shared_mutex
+{
+ static int lock_count;
+ static int unlock_count;
+ void lock_shared()
+ {
+ ++lock_count;
+ }
+ void unlock_shared()
+ {
+ ++unlock_count;
+ }
+};
+
+int shared_mutex::lock_count = 0;
+int shared_mutex::unlock_count = 0;
+
+shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<shared_mutex> lk(m);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(shared_mutex::lock_count == 1);
+ BOOST_TEST(shared_mutex::unlock_count == 0);
+ BOOST_TEST(lk.release() == &m);
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(shared_mutex::lock_count == 1);
+ BOOST_TEST(shared_mutex::unlock_count == 0);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/mutex_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/mutex_pass.cpp
new file mode 100755
index 0000000000..49c051be92
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/mutex_pass.cpp
@@ -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 shared_lock;
+
+// Mutex *mutex() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<boost::shared_mutex> lk0;
+ BOOST_TEST(lk0.mutex() == 0);
+ boost::shared_lock<boost::shared_mutex> lk1(m);
+ BOOST_TEST(lk1.mutex() == &m);
+ lk1.unlock();
+ BOOST_TEST(lk1.mutex() == &m);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/op_bool_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/op_bool_pass.cpp
new file mode 100755
index 0000000000..71712feef5
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/op_bool_pass.cpp
@@ -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 shared_lock;
+
+// explicit operator bool() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ boost::shared_lock < boost::shared_mutex > lk0;
+ BOOST_TEST(bool(lk0) == false);
+ boost::shared_lock < boost::shared_mutex > lk1(m);
+ BOOST_TEST(bool(lk1) == true);
+ lk1.unlock();
+ BOOST_TEST(bool(lk1) == false);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/owns_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/owns_lock_pass.cpp
new file mode 100755
index 0000000000..900300b6fa
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/obs/owns_lock_pass.cpp
@@ -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 shared_lock;
+
+// bool owns_lock() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ boost::shared_lock<boost::shared_mutex> lk0;
+ BOOST_TEST(lk0.owns_lock() == false);
+ boost::shared_lock<boost::shared_mutex> lk1(m);
+ BOOST_TEST(lk1.owns_lock() == true);
+ lk1.unlock();
+ BOOST_TEST(lk1.owns_lock() == false);
+
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/types_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/types_pass.cpp
new file mode 100755
index 0000000000..f919586dff
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/types_pass.cpp
@@ -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/mutex.hpp>
+
+// <mutex>
+
+// template <class Mutex>
+// class shared_lock
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<boost::shared_lock<boost::shared_mutex>::mutex_type,
+ boost::shared_mutex>::value), "");
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/adopt_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/adopt_lock_pass.cpp
new file mode 100755
index 0000000000..d8532f0971
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/adopt_lock_pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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) 2012 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/shared_lock_guard.hpp>
+
+// template <class Mutex> class shared_lock_guard;
+
+// shared_lock_guard(mutex_type& m, adopt_lock_t);
+
+#include <boost/thread/shared_lock_guard.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#if defined BOOST_THREAD_USES_CHRONO
+typedef boost::chrono::high_resolution_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+#else
+#endif
+
+boost::shared_mutex m;
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ m.lock();
+ boost::shared_lock_guard<boost::shared_mutex> lg(m, boost::adopt_lock);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ m.lock();
+ boost::shared_lock_guard<boost::shared_mutex> lg(m, boost::adopt_lock);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp
new file mode 100755
index 0000000000..4f68b2efe6
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/shared_lock_guard.hpp>
+
+// template <class Mutex> class shared_lock_guard;
+
+// shared_lock_guard& operator=(shared_lock_guard const&) = delete;
+
+#include <boost/thread/shared_lock_guard.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ boost::shared_lock_guard<boost::shared_mutex> lk0(m0);
+ boost::shared_lock_guard<boost::shared_mutex> lk1(m1);
+ lk1 = lk0;
+
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp
new file mode 100755
index 0000000000..a6659ab06f
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/shared_lock_guard.hpp>
+
+// template <class Mutex> class shared_lock_guard;
+
+// shared_lock_guard(shared_lock_guard const&) = delete;
+
+
+#include <boost/thread/shared_lock_guard.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ boost::shared_lock_guard<boost::shared_mutex> lk0(m0);
+ boost::shared_lock_guard<boost::shared_mutex> lk1 = lk0;
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/default_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/default_pass.cpp
new file mode 100755
index 0000000000..1494e153ee
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/default_pass.cpp
@@ -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/shared_lock_guard.hpp>
+
+// template <class Mutex> class shared_lock_guard;
+
+// shared_lock_guard(shared_lock_guard const&) = delete;
+
+#include <boost/thread/shared_lock_guard.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#if defined BOOST_THREAD_USES_CHRONO
+typedef boost::chrono::high_resolution_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef boost::chrono::milliseconds ms;
+typedef boost::chrono::nanoseconds ns;
+#else
+#endif
+
+boost::shared_mutex m;
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ boost::shared_lock_guard<boost::shared_mutex> lg(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ boost::shared_lock_guard<boost::shared_mutex> lg(m);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/types_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/types_pass.cpp
new file mode 100755
index 0000000000..2fe4c9a403
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/shared_lock_guard/types_pass.cpp
@@ -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) 2012 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/shared_lock_guard.hpp>
+
+// <mutex>
+
+// template <class Mutex>
+// class shared_lock_guard
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/shared_lock_guard.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<boost::shared_lock_guard<boost::shared_mutex>::mutex_type,
+ boost::shared_mutex>::value), "");
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp
new file mode 100644
index 0000000000..1d40d903dc
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/adopt_lock_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp
new file mode 100644
index 0000000000..58227670ec
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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);
+
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp
new file mode 100644
index 0000000000..4f666be29c
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp
@@ -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;
+
+// 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);
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp
new file mode 100644
index 0000000000..409d30e819
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/default_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp
new file mode 100644
index 0000000000..9aae0544c9
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/defer_lock_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp
new file mode 100644
index 0000000000..679b19f44f
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/chrono/chrono_io.hpp>
+
+#if defined BOOST_THREAD_USES_CHRONO
+
+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();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::unique_lock<boost::timed_mutex> lk(m, ms(300)+ms(1000));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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)+ms(1000));
+ m.unlock();
+ t.join();
+ }
+
+ return boost::report_errors();
+}
+
+#else
+#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
+#endif
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp
new file mode 100644
index 0000000000..09e5d98fc2
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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);
+ }
+
+
+ {
+
+ boost::unique_lock<boost::mutex> lk1;
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(m0));
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ }
+ return boost::report_errors();
+
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp
new file mode 100644
index 0000000000..ee0d2a8c2c
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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&& 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);
+ }
+ {
+ boost::unique_lock<boost::mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(m))));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::unique_lock<boost::mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_for_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_for_pass.cpp
new file mode 100644
index 0000000000..3c27882d4c
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_for_pass.cpp
@@ -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>
+// unique_lock(shared_lock<mutex_type>&&,
+// const chrono::duration<Rep, Period>&);
+
+#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex>
+ lk(boost::shared_lock<boost::shared_mutex>(m), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_try_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_try_pass.cpp
new file mode 100644
index 0000000000..796be4d996
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_try_pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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(shared_lock&& u, try_to_lock);
+
+#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock );
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex> lk(boost::shared_lock<boost::shared_mutex>(m), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_until_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_until_pass.cpp
new file mode 100644
index 0000000000..be61c91d08
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_shared_lock_until_pass.cpp
@@ -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 Clock, class Duration>
+// unique_lock(shared_lock<mutex_type>&&,
+// const chrono::time_point<Clock, Duration>&);
+
+#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::unique_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex>
+ lk( boost::shared_lock<boost::shared_mutex>(m), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_for_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_for_pass.cpp
new file mode 100644
index 0000000000..bfa2cbb2f4
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_for_pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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(shared_lock<mutex_type>&&,
+// const chrono::duration<Rep, Period>&);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::upgrade_mutex m;
+
+int main()
+{
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m);
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::upgrade_mutex>
+ lk(boost::upgrade_lock<boost::upgrade_mutex>(m), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_pass.cpp
new file mode 100644
index 0000000000..ad7a8e7bf3
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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(upgrade_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::upgrade_mutex m;
+
+int main()
+{
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m);
+ boost::unique_lock<boost::upgrade_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);
+ }
+ {
+ boost::unique_lock<boost::upgrade_mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::upgrade_lock<boost::upgrade_mutex>(m))));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::upgrade_mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::upgrade_mutex> lk( (boost::move(lk0)));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_try_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_try_pass.cpp
new file mode 100644
index 0000000000..e1fa9fc4d7
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_try_pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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(upgrade_lock&& u, try_to_lock);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::upgrade_mutex m;
+
+int main()
+{
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m);
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::move(lk0), boost::try_to_lock );
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::upgrade_lock<boost::upgrade_mutex>(m), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::move(lk0), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::upgrade_mutex> lk(boost::move(lk0), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_until_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_until_pass.cpp
new file mode 100644
index 0000000000..11051e22a5
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_until_pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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(shared_lock<mutex_type>&&,
+// const chrono::time_point<Clock, Duration>&);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::upgrade_mutex m;
+
+int main()
+{
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m);
+ boost::unique_lock<boost::upgrade_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::unique_lock<boost::upgrade_mutex>
+ lk( boost::upgrade_lock<boost::upgrade_mutex>(m), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ boost::unique_lock<boost::upgrade_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::upgrade_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::unique_lock<boost::upgrade_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp
new file mode 100644
index 0000000000..aa393be2c0
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/mutex_pass.cpp
@@ -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;
+
+// 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;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ boost::unique_lock<boost::mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ boost::unique_lock<boost::mutex> ul(m);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp
new file mode 100644
index 0000000000..629cb47049
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#if defined BOOST_THREAD_USES_CHRONO
+
+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();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::unique_lock<boost::timed_mutex> lk(m, Clock::now() + ms(300)+ms(1000));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ ns d = t1 - t0 - ms(250);
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // 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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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();
+}
+
+#else
+#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
+#endif
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp
new file mode 100644
index 0000000000..e542ff9caf
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/try_to_lock_pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ 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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+#else
+// 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();
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp
new file mode 100644
index 0000000000..919637c9ff
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/lock_pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ 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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // 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);
+ }
+#else
+ 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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // 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);
+ }
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp
new file mode 100644
index 0000000000..078b8c7c42
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_for_pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+#if defined BOOST_THREAD_USES_CHRONO
+
+
+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();
+}
+
+#else
+#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
+#endif
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp
new file mode 100644
index 0000000000..af7a8408b3
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_pass.cpp
@@ -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/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();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp
new file mode 100644
index 0000000000..a642cf8fb5
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/try_lock_until_pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+#if defined BOOST_THREAD_USES_CHRONO
+
+
+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();
+}
+
+#else
+#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
+#endif
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp
new file mode 100644
index 0000000000..21a6306a86
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/locking/unlock_pass.cpp
@@ -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;
+
+// bool unlock();
+
+#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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp
new file mode 100644
index 0000000000..b0334907dd
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/member_swap_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp
new file mode 100644
index 0000000000..90ec4b0d3b
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/non_member_swap_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp
new file mode 100644
index 0000000000..c755bc4da1
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp
new file mode 100644
index 0000000000..8eb924205f
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp
new file mode 100644
index 0000000000..21b65a1eff
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp
@@ -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;
+
+// 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);
+ }
+
+ {
+ boost::unique_lock<boost::mutex> lk0;
+ if (lk0) BOOST_TEST(false);
+ boost::unique_lock<boost::mutex> lk1(m);
+ if (!lk1) BOOST_TEST(false);
+ lk1.unlock();
+ if (lk1) BOOST_TEST(false);
+ }
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp
new file mode 100644
index 0000000000..a4d46ec5c0
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp
@@ -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> 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;
+ int i = int(lk0);
+ BOOST_TEST(i == 0);
+ }
+
+ return boost::report_errors();
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp
new file mode 100644
index 0000000000..6a78db9c17
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp
@@ -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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp
new file mode 100644
index 0000000000..db65d79fca
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/types_pass.cpp
@@ -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/mutex.hpp>
+
+// <mutex>
+
+// template <class Mutex>
+// class unique_lock
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+
+#include <boost/thread/mutex.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<boost::unique_lock<boost::mutex>::mutex_type,
+ boost::mutex>::value), "");
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/adopt_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/adopt_lock_pass.cpp
new file mode 100755
index 0000000000..865301c108
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/adopt_lock_pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// upgrade_lock(mutex_type& m, adopt_lock_t);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ boost::shared_mutex m;
+ m.lock();
+ boost::upgrade_lock<boost::shared_mutex> lk(m, boost::adopt_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp
new file mode 100755
index 0000000000..a33c5e6b54
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// upgrade_lock& operator=(upgrade_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ boost::upgrade_lock<boost::shared_mutex> lk0(m0);
+ boost::upgrade_lock<boost::shared_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);
+
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp
new file mode 100755
index 0000000000..1a8557a5d1
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp
@@ -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 upgrade_lock;
+
+// upgrade_lock(upgrade_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ boost::upgrade_lock<boost::shared_mutex> lk0(m0);
+ boost::upgrade_lock<boost::shared_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);
+}
+
+void remove_unused_warning()
+{
+ //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable]
+ //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable]
+
+ (void)boost::system::posix_category;
+ (void)boost::system::errno_ecat;
+ (void)boost::system::native_ecat;
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/default_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/default_pass.cpp
new file mode 100755
index 0000000000..bd8108fb72
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/default_pass.cpp
@@ -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 upgrade_lock;
+
+// upgrade_lock(upgrade_lock const&) = delete;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::upgrade_lock<boost::shared_mutex> ul;
+ BOOST_TEST(!ul.owns_lock());
+ BOOST_TEST(ul.mutex() == 0);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/defer_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/defer_lock_pass.cpp
new file mode 100755
index 0000000000..33a5bf8823
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/defer_lock_pass.cpp
@@ -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 upgrade_lock;
+
+// upgrade_lock(mutex_type& m, adopt_lock_t);
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ boost::shared_mutex m;
+ m.lock();
+ boost::upgrade_lock<boost::shared_mutex> lk(m, boost::defer_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/duration_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/duration_pass.cpp
new file mode 100755
index 0000000000..a62438a8f6
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/duration_pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// template <class Rep, class Period>
+// upgrade_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/chrono/chrono_io.hpp>
+
+boost::shared_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();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::upgrade_lock<boost::shared_mutex> lk(m, ms(300)+ms(1000));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // within 5ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ boost::upgrade_lock<boost::shared_mutex> lk(m, ms(250));
+ BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_assign_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_assign_pass.cpp
new file mode 100755
index 0000000000..2bea7a406b
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_assign_pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/shared_mutex.hpp>
+
+// template <class Mutex> class upgrade_lock;
+
+// upgrade_lock(upgrade_lock const&) = delete;
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m0;
+boost::shared_mutex m1;
+
+int main()
+{
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk0(m0);
+ boost::upgrade_lock<boost::shared_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);
+ }
+ {
+
+ boost::upgrade_lock<boost::shared_mutex> lk1;
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::upgrade_lock<boost::shared_mutex>(m0));
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ }
+ {
+ boost::unique_lock<boost::shared_mutex> lk0(m0);
+ boost::upgrade_lock<boost::shared_mutex> lk1(m1);
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::upgrade_lock<boost::shared_mutex>(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);
+ }
+ {
+
+ boost::upgrade_lock<boost::shared_mutex> lk1;
+ lk1 = BOOST_THREAD_MAKE_RV_REF(boost::upgrade_lock<boost::shared_mutex>(boost::unique_lock<boost::shared_mutex>(m0)));
+ BOOST_TEST(lk1.mutex() == &m0);
+ BOOST_TEST(lk1.owns_lock() == true);
+ }
+ return boost::report_errors();
+
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_pass.cpp
new file mode 100755
index 0000000000..f41c7047b1
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// upgrade_lock& operator=(upgrade_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk0(m);
+ boost::upgrade_lock<boost::shared_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);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::upgrade_lock<boost::shared_mutex>(m))));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_for_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_for_pass.cpp
new file mode 100644
index 0000000000..e2abb3944f
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_for_pass.cpp
@@ -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 upgrade_lock;
+
+// template <class Clock, class Duration>
+// upgrade_lock(shared_lock<mutex_type>&&,
+// const chrono::duration<Rep, Period>&);
+
+#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex>
+ lk(boost::shared_lock<boost::shared_mutex>(m), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_try_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_try_pass.cpp
new file mode 100644
index 0000000000..9cb798051e
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_try_pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// upgrade_lock(shared_lock&& u, try_to_lock);
+
+#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock );
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::shared_lock<boost::shared_mutex>(m), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::upgrade_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock);
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_until_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_until_pass.cpp
new file mode 100644
index 0000000000..66025c6fc4
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_shared_lock_until_pass.cpp
@@ -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 upgrade_lock;
+
+// template <class Clock, class Duration>
+// upgrade_lock(shared_lock<mutex_type>&&,
+// const chrono::time_point<Clock, Duration>&);
+
+#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m);
+ boost::upgrade_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex>
+ lk( boost::shared_lock<boost::shared_mutex>(m), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ boost::upgrade_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+ {
+ boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
+ lk0.release();
+ boost::upgrade_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(lk0.mutex() == 0);
+ BOOST_TEST(lk0.owns_lock() == false);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_unique_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_unique_lock_pass.cpp
new file mode 100644
index 0000000000..8afac6372a
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/move_ctor_unique_lock_pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// upgrade_lock& operator=(unique_lock&& u);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ {
+ boost::unique_lock<boost::shared_mutex> lk0(m);
+ boost::upgrade_lock<boost::shared_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);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk( (boost::unique_lock<boost::shared_mutex>(m)));
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/mutex_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/mutex_pass.cpp
new file mode 100755
index 0000000000..104a171ed9
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/mutex_pass.cpp
@@ -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 upgrade_lock;
+
+// explicit upgrade_lock(Mutex& m);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ boost::upgrade_lock<boost::shared_mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#else
+ //time_point t0 = Clock::now();
+ //time_point t1;
+ {
+ boost::upgrade_lock<boost::shared_mutex> ul(m);
+ //t1 = Clock::now();
+ }
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/time_point_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/time_point_pass.cpp
new file mode 100755
index 0000000000..26ad92ace2
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/time_point_pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// template <class Clock, class Duration>
+// upgrade_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_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();
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::upgrade_lock<boost::shared_mutex> lk(m, Clock::now() + ms(300)+ms(1000));
+ BOOST_TEST(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ boost::upgrade_lock<boost::shared_mutex> lk(m, Clock::now() + ms(250));
+ BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(5000000)+ms(1000)); // 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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/try_to_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/try_to_lock_pass.cpp
new file mode 100755
index 0000000000..9cad5cb6ac
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/cons/try_to_lock_pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// upgrade_lock(mutex_type& m, try_to_lock_t);
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ time_point t0 = Clock::now();
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ BOOST_TEST(lk.owns_lock() == false);
+ }
+ while (true)
+ {
+ boost::upgrade_lock<boost::shared_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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+#else
+// time_point t0 = Clock::now();
+// {
+// boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+// BOOST_TEST(lk.owns_lock() == false);
+// }
+// {
+// boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+// BOOST_TEST(lk.owns_lock() == false);
+// }
+// {
+// boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+// BOOST_TEST(lk.owns_lock() == false);
+// }
+ while (true)
+ {
+ boost::upgrade_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
+ if (lk.owns_lock()) break;
+ }
+ //time_point t1 = Clock::now();
+ //ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/lock_pass.cpp
new file mode 100755
index 0000000000..cf95c3725e
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/lock_pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 upgrade_lock;
+
+// void lock();
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+boost::shared_mutex m;
+
+#if defined BOOST_THREAD_USES_CHRONO
+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;
+#else
+#endif
+
+void f()
+{
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::upgrade_lock < boost::shared_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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(2500000)+ms(1000)); // 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);
+ }
+#else
+ boost::upgrade_lock < boost::shared_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);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ //BOOST_TEST(d < ns(2500000)+ms(1000)); // 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);
+ }
+#endif
+}
+
+int main()
+{
+ m.lock();
+ boost::thread t(f);
+#if defined BOOST_THREAD_USES_CHRONO
+ boost::this_thread::sleep_for(ms(250));
+#else
+#endif
+ m.unlock();
+ t.join();
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_for_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_for_pass.cpp
new file mode 100755
index 0000000000..9298e9473b
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_for_pass.cpp
@@ -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 upgrade_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_for_called = false;
+
+typedef boost::chrono::milliseconds ms;
+
+struct shared_mutex
+{
+ template <class Rep, class Period>
+ bool try_lock_upgrade_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_upgrade()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_pass.cpp
new file mode 100755
index 0000000000..1136ae48e9
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_pass.cpp
@@ -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 upgrade_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_called = false;
+
+struct shared_mutex
+{
+ bool try_lock_upgrade()
+ {
+ try_lock_called = !try_lock_called;
+ return try_lock_called;
+ }
+ void unlock_upgrade()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_until_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_until_pass.cpp
new file mode 100755
index 0000000000..aca6708de3
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/try_lock_until_pass.cpp
@@ -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 upgrade_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool try_lock_until_called = false;
+
+struct shared_mutex
+{
+ template <class Clock, class Duration>
+ bool try_lock_upgrade_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_upgrade()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ typedef boost::chrono::steady_clock Clock;
+ boost::upgrade_lock<shared_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();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/unlock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/unlock_pass.cpp
new file mode 100755
index 0000000000..2116561d66
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/locking/unlock_pass.cpp
@@ -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 upgrade_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/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+bool unlock_called = false;
+
+struct shared_mutex
+{
+ void lock_upgrade()
+ {
+ }
+ void unlock_upgrade()
+ {
+ unlock_called = true;
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/member_swap_pass.cpp
new file mode 100755
index 0000000000..e892aa6317
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/member_swap_pass.cpp
@@ -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 upgrade_lock;
+
+// void swap(upgrade_lock& u);
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct shared_mutex
+{
+ void lock_upgrade()
+ {
+ }
+ void unlock_upgrade()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<shared_mutex> lk1(m);
+ boost::upgrade_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp
new file mode 100755
index 0000000000..b7983bef34
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp
@@ -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(upgrade_lock<Mutex>& x, upgrade_lock<Mutex>& y);
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct shared_mutex
+{
+ void lock_upgrade()
+ {
+ }
+ void unlock_upgrade()
+ {
+ }
+};
+
+shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<shared_mutex> lk1(m);
+ boost::upgrade_lock<shared_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();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/release_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/release_pass.cpp
new file mode 100755
index 0000000000..b5976023c2
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/release_pass.cpp
@@ -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 upgrade_lock;
+
+// void Mutex* release();
+
+#include <boost/thread/locks.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct shared_mutex
+{
+ static int lock_count;
+ static int unlock_count;
+ void lock_upgrade()
+ {
+ ++lock_count;
+ }
+ void unlock_upgrade()
+ {
+ ++unlock_count;
+ }
+};
+
+int shared_mutex::lock_count = 0;
+int shared_mutex::unlock_count = 0;
+
+shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<shared_mutex> lk(m);
+ BOOST_TEST(lk.mutex() == &m);
+ BOOST_TEST(lk.owns_lock() == true);
+ BOOST_TEST(shared_mutex::lock_count == 1);
+ BOOST_TEST(shared_mutex::unlock_count == 0);
+ BOOST_TEST(lk.release() == &m);
+ BOOST_TEST(lk.mutex() == 0);
+ BOOST_TEST(lk.owns_lock() == false);
+ BOOST_TEST(shared_mutex::lock_count == 1);
+ BOOST_TEST(shared_mutex::unlock_count == 0);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/mutex_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/mutex_pass.cpp
new file mode 100755
index 0000000000..a730f2c2bb
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/mutex_pass.cpp
@@ -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 upgrade_lock;
+
+// Mutex *mutex() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<boost::shared_mutex> lk0;
+ BOOST_TEST(lk0.mutex() == 0);
+ boost::upgrade_lock<boost::shared_mutex> lk1(m);
+ BOOST_TEST(lk1.mutex() == &m);
+ lk1.unlock();
+ BOOST_TEST(lk1.mutex() == &m);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/op_bool_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/op_bool_pass.cpp
new file mode 100755
index 0000000000..dedd389994
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/op_bool_pass.cpp
@@ -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 upgrade_lock;
+
+// explicit operator bool() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock < boost::shared_mutex > lk0;
+ BOOST_TEST(bool(lk0) == false);
+ boost::upgrade_lock < boost::shared_mutex > lk1(m);
+ BOOST_TEST(bool(lk1) == true);
+ lk1.unlock();
+ BOOST_TEST(bool(lk1) == false);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/owns_lock_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/owns_lock_pass.cpp
new file mode 100755
index 0000000000..e6969f2cbd
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/obs/owns_lock_pass.cpp
@@ -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 upgrade_lock;
+
+// bool owns_lock() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::shared_mutex m;
+
+int main()
+{
+ boost::upgrade_lock<boost::shared_mutex> lk0;
+ BOOST_TEST(lk0.owns_lock() == false);
+ boost::upgrade_lock<boost::shared_mutex> lk1(m);
+ BOOST_TEST(lk1.owns_lock() == true);
+ lk1.unlock();
+ BOOST_TEST(lk1.owns_lock() == false);
+
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/types_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/types_pass.cpp
new file mode 100755
index 0000000000..660ed5ef85
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/types_pass.cpp
@@ -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/mutex.hpp>
+
+// <mutex>
+
+// template <class Mutex>
+// class upgrade_lock
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<boost::upgrade_lock<boost::upgrade_mutex>::mutex_type,
+ boost::upgrade_mutex>::value), "");
+
+ return boost::report_errors();
+}
+