summaryrefslogtreecommitdiff
path: root/indra/test/sync.h
AgeCommit message (Collapse)Author
2021-12-02Merged in DRTVWR-540-syncpatch (pull request #796)Nat Linden
DRTVWR-540: Make Sync test failure more informative * DRTVWR-540: Make Sync test failure more informative Approved-by: Andrey Kleshchev Approved-by: Andrey Lihatskiy
2020-04-03DRTVWR-476: Use a longer default timeout for Sync class.Nat Goodspeed
The timeout is meant to prevent a deadlocked test program from hanging a build. It's not intended to ensure some sort of SLA for the operations under test. Empirically, using a longer timeout helps some test programs. The only downside of increasing the timeout is that if some test does hang, it takes longer to notice. But changes on the order of a few seconds are negligible.
2020-03-25DRTVWR-476: Make Sync::bump() atomic, add set() method.Nat Goodspeed
Using Sync with multiple threads is trickier than with coroutines. In particular, Sync::bump() was racy (get() and set() as two different operations), and threads were proceeding when they should have waited. Fortunately LLCond, on which Sync is based, already supports atomic update operations. Use that for bump(). But to nail things down even more specifically, add set(n) to complement yield_until(n). Using those methods, there should be no ambiguity about which call in one thread synchronizes with which call in the other thread.
2020-03-25DRTVWR-476: Add Sync class to help with stepwise coroutine tests.Nat Goodspeed
Sync is specifically intended for test programs. It is based on an LLScalarCond<int>. The idea is that each of two coroutines can watch for the other to get a chance to run, indicated by incrementing the wrapped int and notifying the wrapped condition_variable. This is less hand-wavy than calling llcoro::suspend() and hoping that the other routine will have had a chance to run. Use Sync in lleventcoro_test.cpp. Also refactor lleventcoro_test.cpp so that instead of a collection of static data requiring a clear() call at start of each individual test function, the relevant data is all part of the test_data struct common to all test functions. Make the helper coroutine functions members of test_data too. Introduce llcoro::logname(), a convenience function to log the name of the currently executing coroutine or "main" if in the thread's main coroutine.