summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/workqueue.cpp5
-rw-r--r--indra/llcommon/workqueue.h15
2 files changed, 20 insertions, 0 deletions
diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp
index 14ae4c4ab8..633594ceea 100644
--- a/indra/llcommon/workqueue.cpp
+++ b/indra/llcommon/workqueue.cpp
@@ -39,6 +39,11 @@ void LL::WorkQueue::close()
mQueue.close();
}
+size_t LL::WorkQueue::size()
+{
+ return mQueue.size();
+}
+
bool LL::WorkQueue::isClosed()
{
return mQueue.isClosed();
diff --git a/indra/llcommon/workqueue.h b/indra/llcommon/workqueue.h
index 5987883829..c25d787425 100644
--- a/indra/llcommon/workqueue.h
+++ b/indra/llcommon/workqueue.h
@@ -64,6 +64,21 @@ namespace LL
*/
void close();
+ /**
+ * WorkQueue supports multiple producers and multiple consumers. In
+ * the general case it's misleading to test size(), since any other
+ * thread might change it the nanosecond the lock is released. On that
+ * basis, some might argue against publishing a size() method at all.
+ *
+ * But there are two specific cases in which a test based on size()
+ * might be reasonable:
+ *
+ * * If you're the only producer, noticing that size() == 0 is
+ * meaningful.
+ * * If you're the only consumer, noticing that size() > 0 is
+ * meaningful.
+ */
+ size_t size();
/// producer end: are we prevented from pushing any additional items?
bool isClosed();
/// consumer end: are we done, is the queue entirely drained?