comparison DEPENDENCIES/generic/include/boost/interprocess/sync/posix/condition.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
9 ////////////////////////////////////////////////////////////////////////////// 9 //////////////////////////////////////////////////////////////////////////////
10 10
11 #ifndef BOOST_INTERPROCESS_POSIX_CONDITION_HPP 11 #ifndef BOOST_INTERPROCESS_POSIX_CONDITION_HPP
12 #define BOOST_INTERPROCESS_POSIX_CONDITION_HPP 12 #define BOOST_INTERPROCESS_POSIX_CONDITION_HPP
13 13
14 #if (defined _MSC_VER) && (_MSC_VER >= 1200) 14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
16 #endif
17 #
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
15 # pragma once 19 # pragma once
16 #endif 20 #endif
17 21
18 #include <boost/interprocess/detail/config_begin.hpp> 22 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp> 23 #include <boost/interprocess/detail/workaround.hpp>
81 //!and then reacquires the lock. 85 //!and then reacquires the lock.
82 //!Returns: false if time abs_time is reached, otherwise true. 86 //!Returns: false if time abs_time is reached, otherwise true.
83 template <typename L> 87 template <typename L>
84 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time) 88 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
85 { 89 {
90 if (!lock)
91 throw lock_exception();
92 //Posix does not support infinity absolute time so handle it here
86 if(abs_time == boost::posix_time::pos_infin){ 93 if(abs_time == boost::posix_time::pos_infin){
87 this->wait(lock); 94 this->wait(lock);
88 return true; 95 return true;
89 } 96 }
90 if (!lock)
91 throw lock_exception();
92 return this->do_timed_wait(abs_time, *lock.mutex()); 97 return this->do_timed_wait(abs_time, *lock.mutex());
93 } 98 }
94 99
95 //!The same as: while (!pred()) { 100 //!The same as: while (!pred()) {
96 //! if (!timed_wait(lock, abs_time)) return pred(); 101 //! if (!timed_wait(lock, abs_time)) return pred();
97 //! } return true; 102 //! } return true;
98 template <typename L, typename Pr> 103 template <typename L, typename Pr>
99 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred) 104 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
100 { 105 {
106 if (!lock)
107 throw lock_exception();
108 //Posix does not support infinity absolute time so handle it here
101 if(abs_time == boost::posix_time::pos_infin){ 109 if(abs_time == boost::posix_time::pos_infin){
102 this->wait(lock, pred); 110 this->wait(lock, pred);
103 return true; 111 return true;
104 } 112 }
105 if (!lock)
106 throw lock_exception();
107 while (!pred()){ 113 while (!pred()){
108 if (!this->do_timed_wait(abs_time, *lock.mutex())) 114 if (!this->do_timed_wait(abs_time, *lock.mutex()))
109 return pred(); 115 return pred();
110 } 116 }
111
112 return true; 117 return true;
113 } 118 }
114 119
115 120
116 void do_wait(posix_mutex &mut); 121 void do_wait(posix_mutex &mut);