1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_SYNC_DETAIL_COMMON_ALGORITHMS_HPP
12 #define BOOST_INTERPROCESS_SYNC_DETAIL_COMMON_ALGORITHMS_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
25 #include <boost/interprocess/sync/spin/wait.hpp>
28 namespace interprocess {
31 template<class MutexType>
32 bool try_based_timed_lock(MutexType &m, const boost::posix_time::ptime &abs_time)
35 if(abs_time == boost::posix_time::pos_infin){
39 //Always try to lock to achieve POSIX guarantees:
40 // "Under no circumstance shall the function fail with a timeout if the mutex
41 // can be locked immediately. The validity of the abs_timeout parameter need not
42 // be checked if the mutex can be locked immediately."
43 else if(m.try_lock()){
48 while(microsec_clock::universal_time() < abs_time){
58 template<class MutexType>
59 void try_based_lock(MutexType &m)
75 } //namespace ipcdetail
76 } //namespace interprocess
79 #include <boost/interprocess/detail/config_end.hpp>
81 #endif //BOOST_INTERPROCESS_SYNC_DETAIL_COMMON_ALGORITHMS_HPP