Skip to content
Snippets Groups Projects
Commit 877a02db authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

SL-16094: Fix merge glitches from previous revert.

parent d71e0a6d
No related branches found
No related tags found
No related merge requests found
...@@ -85,8 +85,8 @@ class LLThreadSafeQueue ...@@ -85,8 +85,8 @@ class LLThreadSafeQueue
LLThreadSafeQueue(U32 capacity = 1024); LLThreadSafeQueue(U32 capacity = 1024);
virtual ~LLThreadSafeQueue() {} virtual ~LLThreadSafeQueue() {}
// Add an element to the queue (will block if the queue has // Add an element to the queue (will block if the queue has reached
// reached capacity). // capacity).
// //
// This call will raise an interrupt error if the queue is closed while // This call will raise an interrupt error if the queue is closed while
// the caller is blocked. // the caller is blocked.
...@@ -95,6 +95,11 @@ class LLThreadSafeQueue ...@@ -95,6 +95,11 @@ class LLThreadSafeQueue
// legacy name // legacy name
void pushFront(ElementT const & element) { return push(element); } 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 // Try to add an element to the queue without blocking. Returns
// true only if the element was actually added. // true only if the element was actually added.
template <typename T> template <typename T>
...@@ -314,8 +319,8 @@ bool LLThreadSafeQueue<ElementT, QueueT>::push_(lock_t& lock, T&& element) ...@@ -314,8 +319,8 @@ bool LLThreadSafeQueue<ElementT, QueueT>::push_(lock_t& lock, T&& element)
template <typename ElementT, typename QueueT> template <typename ElementT, typename QueueT>
template<typename T> template <typename T>
void LLThreadSafeQueue<ElementT, QueueT>::push(T&& element) bool LLThreadSafeQueue<ElementT, QueueT>::pushIfOpen(T&& element)
{ {
LL_PROFILE_ZONE_SCOPED; LL_PROFILE_ZONE_SCOPED;
lock_t lock1(mLock); lock_t lock1(mLock);
...@@ -325,12 +330,10 @@ void LLThreadSafeQueue<ElementT, QueueT>::push(T&& element) ...@@ -325,12 +330,10 @@ void LLThreadSafeQueue<ElementT, QueueT>::push(T&& element)
// drained or not: the moment either end calls close(), further push() // drained or not: the moment either end calls close(), further push()
// operations will fail. // operations will fail.
if (mClosed) if (mClosed)
{ return false;
LLTHROW(LLThreadSafeQueueInterrupt());
}
if (push_(lock1, std::forward<T>(element))) if (push_(lock1, std::forward<T>(element)))
return; return true;
// Storage Full. Wait for signal. // Storage Full. Wait for signal.
mCapacityCond.wait(lock1); mCapacityCond.wait(lock1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment