Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77292 - trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons
From: vicente.botet_at_[hidden]
Date: 2012-03-10 12:07:40


Author: viboes
Date: 2012-03-10 12:07:39 EST (Sat, 10 Mar 2012)
New Revision: 77292
URL: http://svn.boost.org/trac/boost/changeset/77292

Log:
Thread: Added test for shared_lock move from other locks
Text files modified:
   trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp | 32 +++++++++++++++++++++++++++++++-
   trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp | 28 ++++++++++++++++++++++++++++
   2 files changed, 59 insertions(+), 1 deletions(-)

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_assign_pass.cpp 2012-03-10 12:07:39 EST (Sat, 10 Mar 2012)
@@ -37,12 +37,42 @@
     BOOST_TEST(lk0.mutex() == 0);
     BOOST_TEST(lk0.owns_lock() == false);
   }
+ {
 
+ boost::shared_lock<boost::shared_mutex> lk1;
+ lk1 = 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::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::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::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::shared_lock<boost::shared_mutex>(m0);
+ lk1 = boost::upgrade_lock<boost::shared_mutex>(m0);
     BOOST_TEST(lk1.mutex() == &m0);
     BOOST_TEST(lk1.owns_lock() == true);
   }

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/cons/move_ctor_pass.cpp 2012-03-10 12:07:39 EST (Sat, 10 Mar 2012)
@@ -41,6 +41,34 @@
   BOOST_TEST(lk.owns_lock() == true);
   }
 
+ {
+ 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::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);
+ }
+
   return boost::report_errors();
 }
 


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