diff --git a/doc/sync_queues_ref.qbk b/doc/sync_queues_ref.qbk index c3bf141d..6ce6f5b8 100644 --- a/doc/sync_queues_ref.qbk +++ b/doc/sync_queues_ref.qbk @@ -573,7 +573,7 @@ Closed queues add the following valid expressions [[Return:] [ -- If the queue is closed retun `queue_op_status::closed`, +- If the queue is closed return `queue_op_status::closed`, - otherwise, return `queue_op_status::success` if no exception is thrown. @@ -591,7 +591,7 @@ Closed queues add the following valid expressions [variablelist -[[Effects:] [Waits until the queue is not empty and then pull_front the element from the queue `q` and moves the pulled element into `lve` (this could need an allocation for unbounded queues).]] +[[Effects:] [if the queue is not empty and not closed, waits until the queue is not empty and then pull_front the element from the queue `q` and moves the pulled element into `lve`.]] [[Synchronization:] [Prior pull-like operations on the same object synchronizes with this operation.]] @@ -603,8 +603,6 @@ Closed queues add the following valid expressions - If the queue is empty and closed, return `queue_op_status::closed`, -- otherwise, if the queue is empty, return `queue_op_status::empty`, - - otherwise, return `queue_op_status::success` if no exception is thrown. ]] diff --git a/include/boost/thread/sync_bounded_queue.hpp b/include/boost/thread/sync_bounded_queue.hpp index af5712e6..6127db48 100644 --- a/include/boost/thread/sync_bounded_queue.hpp +++ b/include/boost/thread/sync_bounded_queue.hpp @@ -352,16 +352,16 @@ namespace boost template bool sync_bounded_queue::try_pull(ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); return try_pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -388,34 +388,34 @@ namespace boost template bool sync_bounded_queue::try_pull(no_block_tag,ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_, try_to_lock); if (!lk.owns_lock()) { return false; } return try_pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template boost::shared_ptr sync_bounded_queue::try_pull() { - try - { +// try +// { unique_lock lk(mtx_); return try_pull(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -466,17 +466,17 @@ namespace boost template void sync_bounded_queue::pull(ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } // template // void sync_bounded_queue::pull(ValueType& elem, bool & closed) @@ -499,32 +499,32 @@ namespace boost template ValueType sync_bounded_queue::pull() { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); return pull(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template boost::shared_ptr sync_bounded_queue::ptr_pull() { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); return ptr_pull(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -532,51 +532,51 @@ namespace boost template void sync_bounded_queue::pull_front(ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); pull_front(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } // enable if ValueType is nothrow movable template ValueType sync_bounded_queue::pull_front() { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); return pull_front(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template queue_op_status sync_bounded_queue::wait_pull_front(ValueType& elem, unique_lock& lk) { - try - { - if (closed(lk)) {return queue_op_status::closed;} - if (empty(lk)) {return queue_op_status::empty;} +// try +// { + if (empty(lk) && closed(lk)) {return queue_op_status::closed;} + //if (empty(lk)) {return queue_op_status::empty;} pull_front(elem, lk); return queue_op_status::success; - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template queue_op_status sync_bounded_queue::wait_pull_front(ValueType& elem) @@ -601,16 +601,16 @@ namespace boost template bool sync_bounded_queue::try_push(const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); return try_push(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -645,7 +645,7 @@ namespace boost template queue_op_status sync_bounded_queue::wait_push_back(const ValueType& elem) { - unique_lock& lk(mtx_); + unique_lock lk(mtx_); return wait_push_back(elem, lk); } @@ -654,17 +654,17 @@ namespace boost template bool sync_bounded_queue::try_push(no_block_tag, const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_, try_to_lock); if (!lk.owns_lock()) return false; return try_push(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -696,31 +696,31 @@ namespace boost template void sync_bounded_queue::push(const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); push_at(elem, wait_until_not_full(lk), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template void sync_bounded_queue::push_back(const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); push_at(elem, wait_until_not_full(lk), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD @@ -740,16 +740,16 @@ namespace boost template bool sync_bounded_queue::try_push(BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_); return try_push(boost::move(elem), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -796,20 +796,20 @@ namespace boost template bool sync_bounded_queue::try_push(no_block_tag, BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_, try_to_lock); if (!lk.owns_lock()) { return false; } return try_push(boost::move(elem), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template @@ -827,31 +827,31 @@ namespace boost template void sync_bounded_queue::push(BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_); push_at(boost::move(elem), wait_until_not_full(lk), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template void sync_bounded_queue::push_back(BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_); push_at(boost::move(elem), wait_until_not_full(lk), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template diff --git a/include/boost/thread/sync_queue.hpp b/include/boost/thread/sync_queue.hpp index b781ec23..3968665e 100644 --- a/include/boost/thread/sync_queue.hpp +++ b/include/boost/thread/sync_queue.hpp @@ -319,7 +319,7 @@ namespace boost if (empty(lk)) { if (closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; + //return queue_op_status::empty; } pull_front(elem, lk); return queue_op_status::success; @@ -329,16 +329,16 @@ namespace boost template bool sync_queue::try_pull(ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); return try_pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template @@ -359,34 +359,34 @@ namespace boost template bool sync_queue::try_pull(no_block_tag,ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_, try_to_lock); if (!lk.owns_lock()) { return false; } return try_pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template boost::shared_ptr sync_queue::try_pull() { - try - { +// try +// { unique_lock lk(mtx_); return try_pull(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template @@ -437,99 +437,99 @@ namespace boost template void sync_queue::pull(ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template void sync_queue::pull(ValueType& elem, bool & closed) { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk, closed); if (closed) {return;} pull(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } // enable if ValueType is nothrow movable template ValueType sync_queue::pull() { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); return pull(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template boost::shared_ptr sync_queue::ptr_pull() { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); return ptr_pull(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template void sync_queue::pull_front(ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); pull_front(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } // enable if ValueType is nothrow movable template ValueType sync_queue::pull_front() { - try - { +// try +// { unique_lock lk(mtx_); wait_until_not_empty(lk); return pull_front(lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD @@ -544,16 +544,16 @@ namespace boost template bool sync_queue::try_push(const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); return try_push(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -591,17 +591,17 @@ namespace boost template bool sync_queue::try_push(no_block_tag, const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_, try_to_lock); if (!lk.owns_lock()) return false; return try_push(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template @@ -616,34 +616,34 @@ namespace boost template void sync_queue::push(const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); throw_if_closed(lk); push(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template void sync_queue::push_back(const ValueType& elem) { - try - { +// try +// { unique_lock lk(mtx_); throw_if_closed(lk); push_back(elem, lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD @@ -658,16 +658,16 @@ namespace boost template bool sync_queue::try_push(BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_); return try_push(boost::move(elem), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -705,20 +705,20 @@ namespace boost template bool sync_queue::try_push(no_block_tag, BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_, try_to_lock); if (!lk.owns_lock()) { return false; } return try_push(boost::move(elem), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif @@ -737,34 +737,34 @@ namespace boost template void sync_queue::push(BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_); throw_if_closed(lk); push(boost::move(elem), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } #endif template void sync_queue::push_back(BOOST_THREAD_RV_REF(ValueType) elem) { - try - { +// try +// { unique_lock lk(mtx_); throw_if_closed(lk); push_back(boost::move(elem), lk); - } - catch (...) - { - close(); - throw; - } +// } +// catch (...) +// { +// close(); +// throw; +// } } template