2
0
mirror of https://github.com/boostorg/thread.git synced 2026-01-23 06:02:14 +00:00

try_mutex locks throw if unlocked twice

[SVN r34249]
This commit is contained in:
Anthony Williams
2006-06-08 16:39:21 +00:00
parent 781794aa2d
commit 08041bf58e
2 changed files with 6 additions and 0 deletions

View File

@@ -161,6 +161,10 @@ namespace boost
}
void unlock()
{
if(!locked())
{
throw boost::lock_error();
}
m.unlock();
is_locked=false;
}

View File

@@ -117,6 +117,7 @@ boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
test->add(BOOST_TEST_CASE((test_unlocked_after_unlock_called<boost::try_mutex,boost::try_mutex::scoped_lock>())));
test->add(BOOST_TEST_CASE((test_locked_after_lock_called<boost::try_mutex,boost::try_mutex::scoped_lock>())));
test->add(BOOST_TEST_CASE((test_throws_if_lock_called_when_already_locked<boost::try_mutex,boost::try_mutex::scoped_lock>())));
test->add(BOOST_TEST_CASE((test_throws_if_unlock_called_when_already_unlocked<boost::try_mutex,boost::try_mutex::scoped_lock>())));
test->add(BOOST_TEST_CASE((test_initially_locked<boost::try_mutex,boost::try_mutex::scoped_try_lock>())));
test->add(BOOST_TEST_CASE((test_initially_locked_with_bool_parameter_true<boost::try_mutex,boost::try_mutex::scoped_try_lock>())));
@@ -124,6 +125,7 @@ boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
test->add(BOOST_TEST_CASE((test_unlocked_after_unlock_called<boost::try_mutex,boost::try_mutex::scoped_try_lock>())));
test->add(BOOST_TEST_CASE((test_locked_after_lock_called<boost::try_mutex,boost::try_mutex::scoped_try_lock>())));
test->add(BOOST_TEST_CASE((test_throws_if_lock_called_when_already_locked<boost::try_mutex,boost::try_mutex::scoped_try_lock>())));
test->add(BOOST_TEST_CASE((test_throws_if_unlock_called_when_already_unlocked<boost::try_mutex,boost::try_mutex::scoped_try_lock>())));
return test;
}