From 78d837789a3741c65c3334934d96a505a522ee43 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 24 Nov 2021 09:43:37 -0500 Subject: SL-16400: Make WorkQueue::runFor() and runUntil() stop when done. runFor(interval) and runUntil(timestamp) are intended, and documented, to run *no longer than* the specified time. Instead, the initial implementation always waited the full specified time, hoping for work to arrive. Fix that: once we clear work that's already pending, return right away. --- indra/llcommon/workqueue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp index 1e89d87cff..e7d40354aa 100644 --- a/indra/llcommon/workqueue.cpp +++ b/indra/llcommon/workqueue.cpp @@ -78,8 +78,8 @@ bool LL::WorkQueue::runUntil(const TimePoint& until) LL_PROFILE_ZONE_SCOPED; // Should we subtract some slop to allow for typical Work execution time? // How much slop? - Work work; - while (TimePoint::clock::now() < until && mQueue.tryPopUntil(until, work)) + // runUntil() is simply a time-bounded runPending(). + for (Work work; TimePoint::clock::now() < until && mQueue.tryPop(work); ) { callWork(work); } -- cgit v1.2.3