Boost logo

Boost-Commit :

From: anthony_at_[hidden]
Date: 2008-02-12 15:49:57


Author: anthonyw
Date: 2008-02-12 15:49:56 EST (Tue, 12 Feb 2008)
New Revision: 43227
URL: http://svn.boost.org/trac/boost/changeset/43227

Log:
Pulling changeset 43094 over from trunk
Text files modified:
   branches/release/boost/thread/win32/basic_recursive_mutex.hpp | 6 ++++++
   branches/release/boost/thread/win32/basic_timed_mutex.hpp | 6 ++++++
   branches/release/libs/thread/test/test_mutex.cpp | 11 +++++++++++
   3 files changed, 23 insertions(+), 0 deletions(-)

Modified: branches/release/boost/thread/win32/basic_recursive_mutex.hpp
==============================================================================
--- branches/release/boost/thread/win32/basic_recursive_mutex.hpp (original)
+++ branches/release/boost/thread/win32/basic_recursive_mutex.hpp 2008-02-12 15:49:56 EST (Tue, 12 Feb 2008)
@@ -56,6 +56,12 @@
                 long const current_thread_id=win32::GetCurrentThreadId();
                 return try_recursive_lock(current_thread_id) || try_timed_lock(current_thread_id,target);
             }
+ template<typename Duration>
+ bool timed_lock(Duration const& timeout)
+ {
+ return timed_lock(get_system_time()+timeout);
+ }
+
             long get_active_count()
             {
                 return mutex.get_active_count();

Modified: branches/release/boost/thread/win32/basic_timed_mutex.hpp
==============================================================================
--- branches/release/boost/thread/win32/basic_timed_mutex.hpp (original)
+++ branches/release/boost/thread/win32/basic_timed_mutex.hpp 2008-02-12 15:49:56 EST (Tue, 12 Feb 2008)
@@ -104,6 +104,12 @@
                 return true;
             }
 
+ template<typename Duration>
+ bool timed_lock(Duration const& timeout)
+ {
+ return timed_lock(get_system_time()+timeout);
+ }
+
             long get_active_count()
             {
                 return ::boost::detail::interlocked_read_acquire(&active_count);

Modified: branches/release/libs/thread/test/test_mutex.cpp
==============================================================================
--- branches/release/libs/thread/test/test_mutex.cpp (original)
+++ branches/release/libs/thread/test/test_mutex.cpp 2008-02-12 15:49:56 EST (Tue, 12 Feb 2008)
@@ -150,6 +150,17 @@
         boost::system_time target = boost::get_system_time()+boost::posix_time::milliseconds(100);
         BOOST_CHECK(lock.timed_lock(target));
         BOOST_CHECK(lock ? true : false);
+ lock.unlock();
+ BOOST_CHECK(!lock);
+
+ BOOST_CHECK(mutex.timed_lock(boost::posix_time::milliseconds(100)));
+ mutex.unlock();
+
+ BOOST_CHECK(lock.timed_lock(boost::posix_time::milliseconds(100)));
+ BOOST_CHECK(lock ? true : false);
+ lock.unlock();
+ BOOST_CHECK(!lock);
+
     }
 };
 


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