Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63750 - in trunk: boost/thread boost/thread/detail libs/thread/test
From: anthony_at_[hidden]
Date: 2010-07-08 11:25:46


Author: anthonyw
Date: 2010-07-08 11:25:45 EDT (Thu, 08 Jul 2010)
New Revision: 63750
URL: http://svn.boost.org/trac/boost/changeset/63750

Log:
Ensure futures and shared_mutex work on MSVC-10; fix for issue #2501
Text files modified:
   trunk/boost/thread/detail/thread.hpp | 2 +-
   trunk/boost/thread/locks.hpp | 10 ++++++++--
   trunk/libs/thread/test/test_shared_mutex_part_2.cpp | 9 +++++++++
   3 files changed, 18 insertions(+), 3 deletions(-)

Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp (original)
+++ trunk/boost/thread/detail/thread.hpp 2010-07-08 11:25:45 EDT (Thu, 08 Jul 2010)
@@ -158,7 +158,7 @@
 #ifdef BOOST_MSVC
         template <class F>
         explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0):
- thread_info(make_thread_info(f))
+ thread_info(make_thread_info(static_cast<F&&>(f)))
         {
             start_thread();
         }

Modified: trunk/boost/thread/locks.hpp
==============================================================================
--- trunk/boost/thread/locks.hpp (original)
+++ trunk/boost/thread/locks.hpp 2010-07-08 11:25:45 EDT (Thu, 08 Jul 2010)
@@ -491,6 +491,12 @@
     {
         return static_cast<upgrade_lock<Mutex>&&>(ul);
     }
+
+ template<typename Mutex>
+ inline upgrade_lock<Mutex>&& move(upgrade_lock<Mutex>& ul)
+ {
+ return static_cast<upgrade_lock<Mutex>&&>(ul);
+ }
 #endif
     template<typename Mutex>
     void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs)
@@ -768,14 +774,14 @@
 
         upgrade_lock& operator=(upgrade_lock<Mutex>&& other)
         {
- upgrade_lock temp(other);
+ upgrade_lock temp(static_cast<upgrade_lock<Mutex>&&>(other));
             swap(temp);
             return *this;
         }
 
         upgrade_lock& operator=(unique_lock<Mutex>&& other)
         {
- upgrade_lock temp(other);
+ upgrade_lock temp(static_cast<unique_lock<Mutex>&&>(other));
             swap(temp);
             return *this;
         }

Modified: trunk/libs/thread/test/test_shared_mutex_part_2.cpp
==============================================================================
--- trunk/libs/thread/test/test_shared_mutex_part_2.cpp (original)
+++ trunk/libs/thread/test/test_shared_mutex_part_2.cpp 2010-07-08 11:25:45 EDT (Thu, 08 Jul 2010)
@@ -138,6 +138,14 @@
     CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,reader_count+1);
 }
 
+void test_can_lock_upgrade_to_unique_if_currently_locked_upgrade()
+{
+ boost::shared_mutex mtx;
+ boost::upgrade_lock<boost::shared_mutex> l(mtx);
+ boost::upgrade_to_unique_lock<boost::shared_mutex> ul(l);
+ BOOST_CHECK(ul.owns_lock());
+}
+
 void test_if_other_thread_has_write_lock_try_lock_shared_returns_false()
 {
 
@@ -282,6 +290,7 @@
 
     test->add(BOOST_TEST_CASE(&test_only_one_upgrade_lock_permitted));
     test->add(BOOST_TEST_CASE(&test_can_lock_upgrade_if_currently_locked_shared));
+ test->add(BOOST_TEST_CASE(&test_can_lock_upgrade_to_unique_if_currently_locked_upgrade));
     test->add(BOOST_TEST_CASE(&test_if_other_thread_has_write_lock_try_lock_shared_returns_false));
     test->add(BOOST_TEST_CASE(&test_if_no_thread_has_lock_try_lock_shared_returns_true));
     test->add(BOOST_TEST_CASE(&test_if_other_thread_has_shared_lock_try_lock_shared_returns_true));


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