diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp index 14ae4c4ab826e752d18501bb74556f97d45dd223..633594ceea780b763f9e037a4ca34a18b84e2244 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 5987883829b8c6569d72f3157eb6d050a3ee95cb..c25d78742544980203b357cdd9b19728fc0a5237 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?