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

SL-16094: Add WorkQueue::size() method to support changeset 08336bb4.

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().
parent 08336bb4
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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?
......
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