summaryrefslogtreecommitdiff
path: root/boost/thread/concurrent_queues/sync_priority_queue.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/thread/concurrent_queues/sync_priority_queue.hpp')
-rw-r--r--boost/thread/concurrent_queues/sync_priority_queue.hpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/boost/thread/concurrent_queues/sync_priority_queue.hpp b/boost/thread/concurrent_queues/sync_priority_queue.hpp
index a556910cd6..2c6881f90f 100644
--- a/boost/thread/concurrent_queues/sync_priority_queue.hpp
+++ b/boost/thread/concurrent_queues/sync_priority_queue.hpp
@@ -82,7 +82,7 @@ namespace detail {
return boost::move(result);
}
- Type const& top()
+ Type const& top() const
{
return _elements.front();
}
@@ -249,7 +249,8 @@ namespace concurrent
T sync_priority_queue<T,Container,Cmp>::pull()
{
unique_lock<mutex> lk(super::mtx_);
- super::wait_until_not_empty(lk);
+ const bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
+ if (has_been_closed) super::throw_if_closed(lk);
return pull(lk);
}
@@ -269,7 +270,8 @@ namespace concurrent
void sync_priority_queue<T,Container,Cmp>::pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_);
- super::wait_until_not_empty(lk);
+ const bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
+ if (has_been_closed) super::throw_if_closed(lk);
pull(lk, elem);
}
@@ -280,10 +282,9 @@ namespace concurrent
sync_priority_queue<T,Cont,Cmp>::pull_until(const chrono::time_point<WClock,Duration>& tp, T& elem)
{
unique_lock<mutex> lk(super::mtx_);
- if (queue_op_status::timeout == super::wait_until_not_empty_until(lk, tp))
- return queue_op_status::timeout;
- pull(lk, elem);
- return queue_op_status::success;
+ const queue_op_status rc = super::wait_until_not_empty_or_closed_until(lk, tp);
+ if (rc == queue_op_status::success) pull(lk, elem);
+ return rc;
}
//////////////////////
@@ -292,7 +293,7 @@ namespace concurrent
queue_op_status
sync_priority_queue<T,Cont,Cmp>::pull_for(const chrono::duration<Rep,Period>& dura, T& elem)
{
- return pull_until(clock::now() + dura, elem);
+ return pull_until(chrono::steady_clock::now() + dura, elem);
}
//////////////////////
@@ -334,11 +335,7 @@ namespace concurrent
template <class T,class Container, class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::wait_pull(unique_lock<mutex>& lk, T& elem)
{
- if (super::empty(lk))
- {
- if (super::closed(lk)) return queue_op_status::closed;
- }
- bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
+ const bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
if (has_been_closed) return queue_op_status::closed;
pull(lk, elem);
return queue_op_status::success;
@@ -352,7 +349,6 @@ namespace concurrent
}
//////////////////////
-
template <class T,class Container, class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::nonblocking_pull(T& elem)
{