diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2021-11-10 10:13:38 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2021-11-10 10:13:38 -0500 |
commit | df8e17d8e851c34a83de6c508aba07f6bde12a10 (patch) | |
tree | 31362ef21e89b37a8e563112198c760cb22de77a | |
parent | 08336bb469b8db41809893a2ed26599777383eed (diff) |
SL-16094: Add WorkQueue::size() method to support changeset 08336bb.
We want to skip calling PostMessage() to bump the window thread out of
GetMessage() in any frame with no work functions pending for that thread. That
test depends on being able to sense the size() of the queue. Having converted
to WorkQueue, we need that queue to support size().
-rw-r--r-- | indra/llcommon/workqueue.cpp | 5 | ||||
-rw-r--r-- | indra/llcommon/workqueue.h | 15 |
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? |