DRTVWR-476: Add Sync class to help with stepwise coroutine tests.
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.
Showing
- indra/llcommon/llcoros.h 13 additions, 0 deletionsindra/llcommon/llcoros.h
- indra/llcommon/tests/lleventcoro_test.cpp 49 additions, 53 deletionsindra/llcommon/tests/lleventcoro_test.cpp
- indra/test/CMakeLists.txt 1 addition, 0 deletionsindra/test/CMakeLists.txt
- indra/test/sync.h 85 additions, 0 deletionsindra/test/sync.h
indra/test/sync.h
0 → 100644
Please register or sign in to comment