2
0
mirror of https://github.com/boostorg/thread.git synced 2026-01-27 19:32:11 +00:00

Ensure futures and shared_mutex work on MSVC-10; fix for issue #2501

[SVN r63750]
This commit is contained in:
Anthony Williams
2010-07-08 15:25:45 +00:00
parent 64e6924132
commit e40be775fe
3 changed files with 18 additions and 3 deletions

View File

@@ -158,7 +158,7 @@ namespace boost
#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();
}

View File

@@ -491,6 +491,12 @@ namespace boost
{
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 @@ namespace boost
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;
}

View File

@@ -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<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 @@ 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));