Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86529 - trunk/boost/interprocess/sync/posix
From: igaztanaga_at_[hidden]
Date: 2013-10-31 04:54:12


Author: igaztanaga
Date: 2013-10-31 04:54:12 EDT (Thu, 31 Oct 2013)
New Revision: 86529
URL: http://svn.boost.org/trac/boost/changeset/86529

Log:
Fixes unfinished code in timed_wait for systems without POSIX timeout support, such as Darwin

Text files modified:
   trunk/boost/interprocess/sync/posix/semaphore_wrapper.hpp | 26 ++++++++++++++++++++++++--
   1 files changed, 24 insertions(+), 2 deletions(-)

Modified: trunk/boost/interprocess/sync/posix/semaphore_wrapper.hpp
==============================================================================
--- trunk/boost/interprocess/sync/posix/semaphore_wrapper.hpp Wed Oct 30 18:08:52 2013 (r86528)
+++ trunk/boost/interprocess/sync/posix/semaphore_wrapper.hpp 2013-10-31 04:54:12 EDT (Thu, 31 Oct 2013) (r86529)
@@ -35,7 +35,8 @@
 #include <boost/interprocess/sync/posix/ptime_to_timespec.hpp>
 #else
 #include <boost/interprocess/detail/os_thread_functions.hpp>
-#include <boost/interprocess/sync/spin/wait.hpp>
+#include <boost/interprocess/sync/detail/locks.hpp>
+#include <boost/interprocess/sync/detail/common_algorithms.hpp>
 #endif
 
 namespace boost {
@@ -172,6 +173,26 @@
    return false;
 }
 
+#ifndef BOOST_INTERPROCESS_POSIX_TIMEOUTS
+
+struct semaphore_wrapper_try_wrapper
+{
+ explicit semaphore_wrapper_try_wrapper(sem_t *handle)
+ : m_handle(handle)
+ {}
+
+ void wait()
+ { semaphore_wait(m_handle); }
+
+ bool try_wait()
+ { return semaphore_try_wait(m_handle); }
+
+ private:
+ sem_t *m_handle;
+};
+
+#endif
+
 inline bool semaphore_timed_wait(sem_t *handle, const boost::posix_time::ptime &abs_time)
 {
    #ifdef BOOST_INTERPROCESS_POSIX_TIMEOUTS
@@ -198,7 +219,8 @@
    return false;
    #else //#ifdef BOOST_INTERPROCESS_POSIX_TIMEOUTS
 
- ipcdetail::lock_to_wait<> lw(*this);
+ semaphore_wrapper_try_wrapper swtw(handle);
+ ipcdetail::lock_to_wait<semaphore_wrapper_try_wrapper> lw(swtw);
    return ipcdetail::try_based_timed_lock(lw, abs_time);
 
    #endif //#ifdef BOOST_INTERPROCESS_POSIX_TIMEOUTS


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