mirror of
https://github.com/boostorg/thread.git
synced 2026-02-01 09:02:08 +00:00
don't close the queue when an exception is throw, don't return empty on wait_pull_pull_front.
This commit is contained in:
@@ -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.
|
||||
]]
|
||||
|
||||
|
||||
@@ -352,16 +352,16 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_bounded_queue<ValueType>::try_pull(ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_pull(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -388,34 +388,34 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_bounded_queue<ValueType>::try_pull(no_block_tag,ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_, try_to_lock);
|
||||
if (!lk.owns_lock())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return try_pull(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
template <typename ValueType>
|
||||
boost::shared_ptr<ValueType> sync_bounded_queue<ValueType>::try_pull()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_pull(lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -466,17 +466,17 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
void sync_bounded_queue<ValueType>::pull(ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
pull(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
// template <typename ValueType>
|
||||
// void sync_bounded_queue<ValueType>::pull(ValueType& elem, bool & closed)
|
||||
@@ -499,32 +499,32 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
ValueType sync_bounded_queue<ValueType>::pull()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
return pull(lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
template <typename ValueType>
|
||||
boost::shared_ptr<ValueType> sync_bounded_queue<ValueType>::ptr_pull()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
void sync_bounded_queue<ValueType>::pull_front(ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
pull_front(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
|
||||
// enable if ValueType is nothrow movable
|
||||
template <typename ValueType>
|
||||
ValueType sync_bounded_queue<ValueType>::pull_front()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
return pull_front(lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
queue_op_status sync_bounded_queue<ValueType>::wait_pull_front(ValueType& elem, unique_lock<mutex>& 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 <typename ValueType>
|
||||
queue_op_status sync_bounded_queue<ValueType>::wait_pull_front(ValueType& elem)
|
||||
@@ -601,16 +601,16 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_bounded_queue<ValueType>::try_push(const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_push(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -645,7 +645,7 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
queue_op_status sync_bounded_queue<ValueType>::wait_push_back(const ValueType& elem)
|
||||
{
|
||||
unique_lock<mutex>& lk(mtx_);
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return wait_push_back(elem, lk);
|
||||
}
|
||||
|
||||
@@ -654,17 +654,17 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_bounded_queue<ValueType>::try_push(no_block_tag, const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
void sync_bounded_queue<ValueType>::push(const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
push_at(elem, wait_until_not_full(lk), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
template <typename ValueType>
|
||||
void sync_bounded_queue<ValueType>::push_back(const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
bool sync_bounded_queue<ValueType>::try_push(BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_push(boost::move(elem), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -796,20 +796,20 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_bounded_queue<ValueType>::try_push(no_block_tag, BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
@@ -827,31 +827,31 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
void sync_bounded_queue<ValueType>::push(BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
push_at(boost::move(elem), wait_until_not_full(lk), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
template <typename ValueType>
|
||||
void sync_bounded_queue<ValueType>::push_back(BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
push_at(boost::move(elem), wait_until_not_full(lk), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
|
||||
@@ -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 <typename ValueType>
|
||||
bool sync_queue<ValueType>::try_pull(ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_pull(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
template <typename ValueType>
|
||||
@@ -359,34 +359,34 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_queue<ValueType>::try_pull(no_block_tag,ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_, try_to_lock);
|
||||
if (!lk.owns_lock())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return try_pull(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
template <typename ValueType>
|
||||
boost::shared_ptr<ValueType> sync_queue<ValueType>::try_pull()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_pull(lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
template <typename ValueType>
|
||||
@@ -437,99 +437,99 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
void sync_queue<ValueType>::pull(ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
pull(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
template <typename ValueType>
|
||||
void sync_queue<ValueType>::pull(ValueType& elem, bool & closed)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
ValueType sync_queue<ValueType>::pull()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
return pull(lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
template <typename ValueType>
|
||||
boost::shared_ptr<ValueType> sync_queue<ValueType>::ptr_pull()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
return ptr_pull(lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename ValueType>
|
||||
void sync_queue<ValueType>::pull_front(ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
wait_until_not_empty(lk);
|
||||
pull_front(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
|
||||
// enable if ValueType is nothrow movable
|
||||
template <typename ValueType>
|
||||
ValueType sync_queue<ValueType>::pull_front()
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
bool sync_queue<ValueType>::try_push(const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_push(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -591,17 +591,17 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_queue<ValueType>::try_push(no_block_tag, const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_, try_to_lock);
|
||||
if (!lk.owns_lock()) return false;
|
||||
return try_push(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
template <typename ValueType>
|
||||
@@ -616,34 +616,34 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
void sync_queue<ValueType>::push(const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
throw_if_closed(lk);
|
||||
push(elem, lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename ValueType>
|
||||
void sync_queue<ValueType>::push_back(const ValueType& elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
bool sync_queue<ValueType>::try_push(BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
return try_push(boost::move(elem), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -705,20 +705,20 @@ namespace boost
|
||||
template <typename ValueType>
|
||||
bool sync_queue<ValueType>::try_push(no_block_tag, BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> 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 <typename ValueType>
|
||||
void sync_queue<ValueType>::push(BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
throw_if_closed(lk);
|
||||
push(boost::move(elem), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename ValueType>
|
||||
void sync_queue<ValueType>::push_back(BOOST_THREAD_RV_REF(ValueType) elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try
|
||||
// {
|
||||
unique_lock<mutex> lk(mtx_);
|
||||
throw_if_closed(lk);
|
||||
push_back(boost::move(elem), lk);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// close();
|
||||
// throw;
|
||||
// }
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
|
||||
Reference in New Issue
Block a user