From e40be775fe40d7968fcdf54d040af8b970d8aef7 Mon Sep 17 00:00:00 2001 From: Anthony Williams Date: Thu, 8 Jul 2010 15:25:45 +0000 Subject: [PATCH] Ensure futures and shared_mutex work on MSVC-10; fix for issue #2501 [SVN r63750] --- include/boost/thread/detail/thread.hpp | 2 +- include/boost/thread/locks.hpp | 10 ++++++++-- test/test_shared_mutex_part_2.cpp | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp index 8b61a4ef..26224baa 100644 --- a/include/boost/thread/detail/thread.hpp +++ b/include/boost/thread/detail/thread.hpp @@ -158,7 +158,7 @@ namespace boost #ifdef BOOST_MSVC template explicit thread(F f,typename disable_if >, dummy* >::type=0): - thread_info(make_thread_info(f)) + thread_info(make_thread_info(static_cast(f))) { start_thread(); } diff --git a/include/boost/thread/locks.hpp b/include/boost/thread/locks.hpp index 799c46dd..d23e6194 100644 --- a/include/boost/thread/locks.hpp +++ b/include/boost/thread/locks.hpp @@ -491,6 +491,12 @@ namespace boost { return static_cast&&>(ul); } + + template + inline upgrade_lock&& move(upgrade_lock& ul) + { + return static_cast&&>(ul); + } #endif template void swap(unique_lock& lhs,unique_lock& rhs) @@ -768,14 +774,14 @@ namespace boost upgrade_lock& operator=(upgrade_lock&& other) { - upgrade_lock temp(other); + upgrade_lock temp(static_cast&&>(other)); swap(temp); return *this; } upgrade_lock& operator=(unique_lock&& other) { - upgrade_lock temp(other); + upgrade_lock temp(static_cast&&>(other)); swap(temp); return *this; } diff --git a/test/test_shared_mutex_part_2.cpp b/test/test_shared_mutex_part_2.cpp index ae38838b..bd5d1b9b 100644 --- a/test/test_shared_mutex_part_2.cpp +++ b/test/test_shared_mutex_part_2.cpp @@ -138,6 +138,14 @@ void test_can_lock_upgrade_if_currently_locked_shared() 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 l(mtx); + boost::upgrade_to_unique_lock ul(l); + BOOST_CHECK(ul.owns_lock()); +} + void test_if_other_thread_has_write_lock_try_lock_shared_returns_false() { @@ -282,6 +290,7 @@ boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[]) 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));