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
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
21 #include <boost/interprocess/sync/spin/wait.hpp>
24 namespace interprocess {
27 template<class MutexType>
28 bool try_based_timed_lock(MutexType &m, const boost::posix_time::ptime &abs_time)
31 if(abs_time == boost::posix_time::pos_infin){
35 //Always try to lock to achieve POSIX guarantees:
36 // "Under no circumstance shall the function fail with a timeout if the mutex
37 // can be locked immediately. The validity of the abs_timeout parameter need not
38 // be checked if the mutex can be locked immediately."
39 else if(m.try_lock()){
44 while(microsec_clock::universal_time() < abs_time){
54 template<class MutexType>
55 void try_based_lock(MutexType &m)
71 } //namespace ipcdetail
72 } //namespace interprocess
75 #include <boost/interprocess/detail/config_end.hpp>
77 #endif //BOOST_INTERPROCESS_SYNC_DETAIL_COMMON_ALGORITHMS_HPP