Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/interprocess/sync/spin/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_DETAIL_SPIN_CONDITION_HPP | 11 #ifndef BOOST_INTERPROCESS_DETAIL_SPIN_CONDITION_HPP |
12 #define BOOST_INTERPROCESS_DETAIL_SPIN_CONDITION_HPP | 12 #define BOOST_INTERPROCESS_DETAIL_SPIN_CONDITION_HPP |
13 | 13 |
14 #ifndef BOOST_CONFIG_HPP | |
15 # include <boost/config.hpp> | |
16 #endif | |
17 # | |
18 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
19 # pragma once | |
20 #endif | |
21 | |
14 #include <boost/interprocess/detail/config_begin.hpp> | 22 #include <boost/interprocess/detail/config_begin.hpp> |
15 #include <boost/interprocess/detail/workaround.hpp> | 23 #include <boost/interprocess/detail/workaround.hpp> |
16 #include <boost/interprocess/sync/spin/mutex.hpp> | 24 #include <boost/interprocess/sync/spin/mutex.hpp> |
17 #include <boost/interprocess/detail/posix_time_types_wrk.hpp> | 25 #include <boost/interprocess/detail/posix_time_types_wrk.hpp> |
18 #include <boost/interprocess/detail/atomic.hpp> | 26 #include <boost/interprocess/detail/atomic.hpp> |
19 #include <boost/interprocess/sync/scoped_lock.hpp> | 27 #include <boost/interprocess/sync/scoped_lock.hpp> |
20 #include <boost/interprocess/exceptions.hpp> | 28 #include <boost/interprocess/exceptions.hpp> |
21 #include <boost/interprocess/detail/os_thread_functions.hpp> | 29 #include <boost/interprocess/detail/os_thread_functions.hpp> |
22 #include <boost/interprocess/sync/spin/wait.hpp> | 30 #include <boost/interprocess/sync/spin/wait.hpp> |
23 #include <boost/move/move.hpp> | 31 #include <boost/move/utility_core.hpp> |
24 #include <boost/cstdint.hpp> | 32 #include <boost/cstdint.hpp> |
25 | 33 |
26 namespace boost { | 34 namespace boost { |
27 namespace interprocess { | 35 namespace interprocess { |
28 namespace ipcdetail { | 36 namespace ipcdetail { |
39 void notify_all(); | 47 void notify_all(); |
40 | 48 |
41 template <typename L> | 49 template <typename L> |
42 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time) | 50 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time) |
43 { | 51 { |
52 if (!lock) | |
53 throw lock_exception(); | |
54 //Handle infinity absolute time here to avoid complications in do_timed_wait | |
44 if(abs_time == boost::posix_time::pos_infin){ | 55 if(abs_time == boost::posix_time::pos_infin){ |
45 this->wait(lock); | 56 this->wait(lock); |
46 return true; | 57 return true; |
47 } | 58 } |
59 return this->do_timed_wait(abs_time, *lock.mutex()); | |
60 } | |
61 | |
62 template <typename L, typename Pr> | |
63 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred) | |
64 { | |
48 if (!lock) | 65 if (!lock) |
49 throw lock_exception(); | 66 throw lock_exception(); |
50 return this->do_timed_wait(abs_time, *lock.mutex()); | 67 //Handle infinity absolute time here to avoid complications in do_timed_wait |
51 } | |
52 | |
53 template <typename L, typename Pr> | |
54 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred) | |
55 { | |
56 if(abs_time == boost::posix_time::pos_infin){ | 68 if(abs_time == boost::posix_time::pos_infin){ |
57 this->wait(lock, pred); | 69 this->wait(lock, pred); |
58 return true; | 70 return true; |
59 } | 71 } |
60 if (!lock) | |
61 throw lock_exception(); | |
62 while (!pred()){ | 72 while (!pred()){ |
63 if (!this->do_timed_wait(abs_time, *lock.mutex())) | 73 if (!this->do_timed_wait(abs_time, *lock.mutex())) |
64 return pred(); | 74 return pred(); |
65 } | 75 } |
66 return true; | 76 return true; |
110 m_num_waiters = 0; | 120 m_num_waiters = 0; |
111 } | 121 } |
112 | 122 |
113 inline spin_condition::~spin_condition() | 123 inline spin_condition::~spin_condition() |
114 { | 124 { |
115 //Trivial destructor | 125 //Notify all waiting threads |
126 //to allow POSIX semantics on condition destruction | |
127 this->notify_all(); | |
116 } | 128 } |
117 | 129 |
118 inline void spin_condition::notify_one() | 130 inline void spin_condition::notify_one() |
119 { | 131 { |
120 this->notify(NOTIFY_ONE); | 132 this->notify(NOTIFY_ONE); |