mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1798651 Part 1: Make SynchronousTask accept a wait interval, and return result. r=gfx-reviewers,nical
This change preserves the existing looping behavior for the indefinite wait. Differential Revision: https://phabricator.services.mozilla.com/D161194
This commit is contained in:
parent
68cd95c000
commit
9a1afee97e
@ -20,10 +20,21 @@ class MOZ_STACK_CLASS SynchronousTask {
|
||||
explicit SynchronousTask(const char* name)
|
||||
: mMonitor(name), mAutoEnter(mMonitor), mDone(false) {}
|
||||
|
||||
void Wait() {
|
||||
while (!mDone) {
|
||||
nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT) {
|
||||
// For indefinite timeouts, wait in a while loop to handle spurious
|
||||
// wakeups.
|
||||
while (aInterval == PR_INTERVAL_NO_TIMEOUT && !mDone) {
|
||||
mMonitor.Wait();
|
||||
}
|
||||
|
||||
// For finite timeouts, we only check once for completion, and otherwise
|
||||
// rely on the ReentrantMonitor to manage the interval. If the monitor
|
||||
// returns too early, we'll never know.
|
||||
if (!mDone) {
|
||||
return mMonitor.Wait(aInterval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user