Commit Graph

7 Commits (7d7aff43779917f5e5fd8c616ec5765e7fb01fb5)

Author SHA1 Message Date
Nat Goodspeed 04ebc11a2d SL-16094: Fix WorkQueue test for correct behavior of runFor().
Turns out that one of our WorkQueue integration tests was relying on the
incorrect runFor() behavior that we just fixed, so the test broke. Now that
runFor() doesn't wait around for work to be posted, use an explicit wait loop
instead.

To support this, add LLCond::get(functor), where functor must accept a const
reference to the stored data. This new get() returns whatever the functor
returns, allowing a caller to peek at the stored data.

Also use universal references for all remaining LLCond functor arguments.
2021-11-24 12:56:48 -05:00
Nat Goodspeed 0b066539fe DRTVWR-546, SL-16220, SL-16094: Undo previous glthread branch revert.
Reverting a merge is sticky: it tells git you never want to see that branch
again. Merging the DRTVWR-546 branch, which contained the revert, into the
glthread branch undid much of the development work on that branch. To restore
it we must revert the revert.

This reverts commit 029b41c041.
2021-11-24 10:47:54 -05:00
Dave Houlton 029b41c041 Revert "SL-16220: Merge branch 'origin/DRTVWR-546' into glthread"
This reverts commit 5188a26a85, reversing
changes made to 819088563e.
2021-11-15 09:25:35 -07:00
Nat Goodspeed 8b16ecb9cf SL-16220: Add tests for WorkQueue::waitForResult(), void & non-void. 2021-10-27 15:31:54 -04:00
Nat Goodspeed e7b8c27741 SL-16220: Specialize WorkQueue for callable with void return.
Add a test exercising this feature.
2021-10-25 15:55:49 -04:00
Nat Goodspeed c585ddb75e SL-16024: Defend against two threads making "anonymous" WorkQueues.
Also make workqueue_test.cpp more robust.
2021-10-07 16:45:15 -04:00
Nat Goodspeed 623ac79120 SL-16024: Add LL::WorkQueue for passing work items between threads.
A typical WorkQueue has a string name, which can be used to find it to post
work to it. "Work" is a nullary callable.

WorkQueue is a multi-producer, multi-consumer thread-safe queue: multiple
threads can service the WorkQueue, multiple threads can post work to it.

Work can be scheduled in the future by submitting with a timestamp. In
addition, a given work item can be scheduled to run on a recurring basis.

A requesting thread servicing a WorkQueue of its own, such as the viewer's
main thread, can submit work to another WorkQueue along with a callback to be
passed the result (of arbitrary type) of the first work item. The callback is
posted to the originating WorkQueue, permitting safe data exchange between
participating threads.

Methods are provided for different kinds of servicing threads. runUntilClose()
is useful for a simple worker thread. runFor(duration) devotes no more than a
specified time slice to that WorkQueue, e.g. for use by the main thread.
2021-10-07 15:32:51 -04:00