diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2021-11-24 09:38:56 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2021-11-24 09:38:56 -0500 |
commit | 877a02dba1df8a5d7d9f40b04d6be834ed9864da (patch) | |
tree | b5b8ddb2c572d0b5c0466cdc943a20c5c8ce370f /indra/llcommon | |
parent | d71e0a6d4778d4c67b8793ba569fee2db226bc8e (diff) |
SL-16094: Fix merge glitches from previous revert.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llthreadsafequeue.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index a588175074..2806506550 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -85,8 +85,8 @@ public: LLThreadSafeQueue(U32 capacity = 1024); virtual ~LLThreadSafeQueue() {} - // Add an element to the queue (will block if the queue has - // reached capacity). + // Add an element to the queue (will block if the queue has reached + // capacity). // // This call will raise an interrupt error if the queue is closed while // the caller is blocked. @@ -95,6 +95,11 @@ public: // legacy name void pushFront(ElementT const & element) { return push(element); } + // Add an element to the queue (will block if the queue has reached + // capacity). Return false if the queue is closed before push is possible. + template <typename T> + bool pushIfOpen(T&& element); + // Try to add an element to the queue without blocking. Returns // true only if the element was actually added. template <typename T> @@ -314,8 +319,8 @@ bool LLThreadSafeQueue<ElementT, QueueT>::push_(lock_t& lock, T&& element) template <typename ElementT, typename QueueT> -template<typename T> -void LLThreadSafeQueue<ElementT, QueueT>::push(T&& element) +template <typename T> +bool LLThreadSafeQueue<ElementT, QueueT>::pushIfOpen(T&& element) { LL_PROFILE_ZONE_SCOPED; lock_t lock1(mLock); @@ -325,12 +330,10 @@ void LLThreadSafeQueue<ElementT, QueueT>::push(T&& element) // drained or not: the moment either end calls close(), further push() // operations will fail. if (mClosed) - { - LLTHROW(LLThreadSafeQueueInterrupt()); - } + return false; if (push_(lock1, std::forward<T>(element))) - return; + return true; // Storage Full. Wait for signal. mCapacityCond.wait(lock1); |