|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2007-12-05 05:58:45
Author: anthonyw
Date: 2007-12-05 05:58:45 EST (Wed, 05 Dec 2007)
New Revision: 41741
URL: http://svn.boost.org/trac/boost/changeset/41741
Log:
improved timeout checks
Text files modified:
trunk/libs/thread/test/test_mutex.cpp | 14 +++++++++++---
trunk/libs/thread/test/test_shared_mutex_part_2.cpp | 3 ++-
2 files changed, 13 insertions(+), 4 deletions(-)
Modified: trunk/libs/thread/test/test_mutex.cpp
==============================================================================
--- trunk/libs/thread/test/test_mutex.cpp (original)
+++ trunk/libs/thread/test/test_mutex.cpp 2007-12-05 05:58:45 EST (Wed, 05 Dec 2007)
@@ -102,6 +102,11 @@
typedef M mutex_type;
typedef typename M::scoped_timed_lock timed_lock_type;
+ static bool fake_predicate()
+ {
+ return false;
+ }
+
void operator()()
{
mutex_type mutex;
@@ -123,14 +128,17 @@
BOOST_CHECK(lock ? true : false);
// Construct and initialize an xtime for a fast time out.
- boost::xtime xt = delay(0, 100);
+ boost::system_time timeout = boost::get_system_time()+boost::posix_time::milliseconds(100);
// Test the lock and the mutex with condition variables.
// No one is going to notify this condition variable. We expect to
// time out.
- BOOST_CHECK(!condition.timed_wait(lock, xt));
+ BOOST_CHECK(!condition.timed_wait(lock, timeout, fake_predicate));
BOOST_CHECK(lock ? true : false);
- BOOST_CHECK(in_range(xt));
+
+ boost::system_time now=boost::get_system_time();
+ boost::posix_time::milliseconds const timeout_resolution(20);
+ BOOST_CHECK((now-timeout_resolution)<timeout);
// Test the lock, unlock and timedlock methods.
lock.unlock();
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 2007-12-05 05:58:45 EST (Wed, 05 Dec 2007)
@@ -241,8 +241,9 @@
boost::system_time const start=boost::get_system_time();
boost::system_time const timeout=start+boost::posix_time::milliseconds(2000);
+ boost::posix_time::milliseconds const timeout_resolution(20);
bool const timed_lock_succeeded=rw_mutex.timed_lock_shared(timeout);
- BOOST_CHECK(in_range(boost::get_xtime(timeout),1));
+ BOOST_CHECK((timeout-timeout_resolution)<boost::get_system_time());
BOOST_CHECK(!timed_lock_succeeded);
if(timed_lock_succeeded)
{
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