summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests/threadsafeschedule_test.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2021-10-06 12:54:29 -0400
committerNat Goodspeed <nat@lindenlab.com>2021-10-06 12:54:29 -0400
commitcf70766b4504f7ee745822926c526ed9c86c9339 (patch)
treeee243808c75413d3d564cc9636d55783756f640f /indra/llcommon/tests/threadsafeschedule_test.cpp
parent955b967623983cb50ba09f7b82e5f01f2c6bcebb (diff)
SL-16024: Fix ThreadSafeSchedule::tryPopFor(), tryPopUntil().
ThreadSafeSchedule::tryPopUntil() (and therefore tryPopFor()) was simply delegating to LLThreadSafeQueue::tryPopUntil(), with an adjusted timeout since we want to wake up as soon as the head item, if any, becomes ready. But then we have to loop back to retry the pop to actually deal with that head item. In addition, ThreadSafeSchedule::popWithTime() was spinning rather than properly blocking on a timed condition variable. Fixed.
Diffstat (limited to 'indra/llcommon/tests/threadsafeschedule_test.cpp')
-rw-r--r--indra/llcommon/tests/threadsafeschedule_test.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/indra/llcommon/tests/threadsafeschedule_test.cpp b/indra/llcommon/tests/threadsafeschedule_test.cpp
index ec0fa0c928..af67b9f492 100644
--- a/indra/llcommon/tests/threadsafeschedule_test.cpp
+++ b/indra/llcommon/tests/threadsafeschedule_test.cpp
@@ -47,6 +47,8 @@ namespace tut
// the timestamp for each one -- but since we're passing explicit
// timestamps, make the queue reorder them.
queue.push(Queue::TimeTuple(Queue::Clock::now() + 20ms, "ghi"));
+ // Given the various push() overloads, you have to match the type
+ // exactly: conversions are ambiguous.
queue.push("abc"s);
queue.push(Queue::Clock::now() + 10ms, "def");
queue.close();
@@ -56,9 +58,11 @@ namespace tut
ensure_equals("failed to pop second", std::get<0>(entry), "def"s);
ensure("queue not closed", queue.isClosed());
ensure("queue prematurely done", ! queue.done());
- entry = queue.pop();
- ensure_equals("failed to pop third", std::get<0>(entry), "ghi"s);
- bool popped = queue.tryPop(entry);
+ std::string s;
+ bool popped = queue.tryPopFor(1s, s);
+ ensure("failed to pop third", popped);
+ ensure_equals("third is wrong", s, "ghi"s);
+ popped = queue.tryPop(s);
ensure("queue not empty", ! popped);
ensure("queue not done", queue.done());
}