Age | Commit message (Collapse) | Author |
|
Instead, introduce bool CoroData::isMain and test that. Use "main" for the
name of the main coroutine. That eliminates the logname() method, also the
llcoro::logname() free function. It also obviates the alternate CoroData
constructor.
Use boost::fibers::fiber::id as the LLInstanceTracker key for CoroData,
instead of the coroutine name. Introduce get_CoroData(id), also getName(id).
Extract static CoroData for the main coroutine to main_CoroData() so both
get_CoroData() overloads can use it.
Ditch unused get_CoroData(string) parameter: now get_CoroData().
Introduce LLCoros::mNameMap for lookup by name (e.g. killreq()). CoroData's
constructor puts an entry into mNameMap; the destructor removes it. Since
mNameMap is thread_local (unlike an LLInstanceTracker key), that theoretically
permits duplicate coroutine names on different threads.
Introduce mPrefixMap to help generate distinct coroutine names, instead of a
single scalar.
Introduce CoroData::getName(), and use it in both LLCoros::getName()
overloads. CoroData::getName() appends mStatus if it's not empty. This is
useful for disambiguating generic pool coroutines based on the current task.
|
|
LF, and trim trailing whitespaces as needed
|
|
DRTVWR-540: Make Sync test failure more informative
* DRTVWR-540: Make Sync test failure more informative
Approved-by: Andrey Kleshchev
Approved-by: Andrey Lihatskiy
|
|
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.
|
|
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.
|
|
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.
|