diff -r bd29b3e4c72d -r abf2ee553b11 include/boost/interprocess/sync/interprocess_condition.hpp
a
|
b
|
|
72 | 72 | |
73 | 73 | //!If there is a thread waiting on *this, change that |
74 | 74 | //!thread's state to ready. Otherwise there is no effect. |
75 | | void notify_one() |
76 | | { m_condition.notify_one(); } |
| 75 | bool notify_one(const boost::posix_time::ptime &abs_time) |
| 76 | { return m_condition.notify_one(abs_time); } |
77 | 77 | |
78 | 78 | //!Change the state of all threads waiting on *this to ready. |
79 | 79 | //!If there are no waiting threads, notify_all() has no effect. |
80 | | void notify_all() |
81 | | { m_condition.notify_all(); } |
| 80 | bool notify_all(const boost::posix_time::ptime &abs_time) |
| 81 | { return m_condition.notify_all(abs_time); } |
82 | 82 | |
83 | 83 | //!Releases the lock on the interprocess_mutex object associated with lock, blocks |
84 | 84 | //!the current thread of execution until readied by a call to |
diff -r bd29b3e4c72d -r abf2ee553b11 include/boost/interprocess/sync/spin/condition.hpp
a
|
b
|
|
34 | 34 | spin_condition(); |
35 | 35 | ~spin_condition(); |
36 | 36 | |
37 | | void notify_one(); |
38 | | void notify_all(); |
| 37 | bool notify_one(const boost::posix_time::ptime &abs_time); |
| 38 | bool notify_all(const boost::posix_time::ptime &abs_time); |
39 | 39 | |
40 | 40 | template <typename L> |
41 | 41 | bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time) |
… |
… |
|
97 | 97 | spin_mutex m_enter_mut; |
98 | 98 | volatile boost::uint32_t m_command; |
99 | 99 | volatile boost::uint32_t m_num_waiters; |
100 | | void notify(boost::uint32_t command); |
| 100 | bool notify(boost::uint32_t command, const boost::posix_time::ptime &abs_time); |
101 | 101 | }; |
102 | 102 | |
103 | 103 | inline spin_condition::spin_condition() |
… |
… |
|
114 | 114 | //Trivial destructor |
115 | 115 | } |
116 | 116 | |
117 | | inline void spin_condition::notify_one() |
| 117 | inline bool spin_condition::notify_one(const boost::posix_time::ptime &abs_time) |
118 | 118 | { |
119 | | this->notify(NOTIFY_ONE); |
| 119 | return this->notify(NOTIFY_ONE, abs_time); |
120 | 120 | } |
121 | 121 | |
122 | | inline void spin_condition::notify_all() |
| 122 | inline bool spin_condition::notify_all(const boost::posix_time::ptime &abs_time) |
123 | 123 | { |
124 | | this->notify(NOTIFY_ALL); |
| 124 | return this->notify(NOTIFY_ALL, abs_time); |
125 | 125 | } |
126 | 126 | |
127 | | inline void spin_condition::notify(boost::uint32_t command) |
| 127 | inline bool spin_condition::notify(boost::uint32_t command, |
| 128 | const boost::posix_time::ptime &abs_time) |
128 | 129 | { |
129 | 130 | //This mutex guarantees that no other thread can enter to the |
130 | 131 | //do_timed_wait method logic, so that thread count will be |
131 | 132 | //constant until the function writes a NOTIFY_ALL command. |
132 | 133 | //It also guarantees that no other notification can be signaled |
133 | 134 | //on this spin_condition before this one ends |
134 | | m_enter_mut.lock(); |
| 135 | |
| 136 | //Fix the situation where one process dies while having m_enter_mut locked |
| 137 | //by providing a timeout on the lock call |
| 138 | if(!m_enter_mut.timed_lock(abs_time)){ |
| 139 | return false; |
| 140 | } |
135 | 141 | |
136 | 142 | //Return if there are no waiters |
137 | 143 | if(!atomic_read32(&m_num_waiters)) { |
138 | 144 | m_enter_mut.unlock(); |
139 | | return; |
| 145 | return true; |
140 | 146 | } |
141 | 147 | |
142 | 148 | //Notify that all threads should execute wait logic |
… |
… |
|
150 | 156 | } |
151 | 157 | */ |
152 | 158 | //The enter mutex will rest locked until the last waiting thread unlocks it |
| 159 | return true; |
153 | 160 | } |
154 | 161 | |
155 | 162 | template<class InterprocessMutex> |