summaryrefslogtreecommitdiff
path: root/boost/thread/concurrent_queues/sync_queue.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
commitb8cf34c691623e4ec329053cbbf68522a855882d (patch)
tree34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/thread/concurrent_queues/sync_queue.hpp
parent3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff)
downloadboost-upstream/1.67.0.tar.gz
boost-upstream/1.67.0.tar.bz2
boost-upstream/1.67.0.zip
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/thread/concurrent_queues/sync_queue.hpp')
-rw-r--r--boost/thread/concurrent_queues/sync_queue.hpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/boost/thread/concurrent_queues/sync_queue.hpp b/boost/thread/concurrent_queues/sync_queue.hpp
index 1dbbef05dd..b36b57e607 100644
--- a/boost/thread/concurrent_queues/sync_queue.hpp
+++ b/boost/thread/concurrent_queues/sync_queue.hpp
@@ -10,7 +10,6 @@
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
-#include <iostream>
#include <boost/thread/detail/config.hpp>
#include <boost/thread/concurrent_queues/detail/sync_queue_base.hpp>
@@ -51,7 +50,6 @@ namespace concurrent
inline ~sync_queue();
// Modifiers
-
inline void push(const value_type& x);
inline queue_op_status try_push(const value_type& x);
inline queue_op_status nonblocking_push(const value_type& x);
@@ -151,19 +149,9 @@ namespace concurrent
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_pull(ValueType& elem, unique_lock<mutex>& lk)
{
- //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
- if (super::empty(lk))
- {
- //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
- if (super::closed(lk)) return queue_op_status::closed;
- }
- //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
- bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
- //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ const bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
if (has_been_closed) return queue_op_status::closed;
- //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
pull(elem, lk);
- //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
return queue_op_status::success;
}
@@ -196,7 +184,8 @@ namespace concurrent
void sync_queue<ValueType, Container>::pull(ValueType& 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(elem, lk);
}
@@ -205,7 +194,8 @@ namespace concurrent
ValueType sync_queue<ValueType, Container>::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);
}