From a76209d099c3a18967d26e5b091f83e9ae9fd6a1 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 22 Oct 2024 09:44:43 -0400 Subject: Eliminate double names for coros + "empty name is main" convention. 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. --- indra/test/sync.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/test') diff --git a/indra/test/sync.h b/indra/test/sync.h index 82eef1e5f5..abeb4e17a8 100644 --- a/indra/test/sync.h +++ b/indra/test/sync.h @@ -69,7 +69,7 @@ public: // misleading, as it will be emitted after waiting threads have // already awakened. But emitting the log message within the lock // would seem to hold the lock longer than we really ought. - LL_DEBUGS() << llcoro::logname() << " bump(" << n << ") -> " << updated << LL_ENDL; + LL_DEBUGS() << LLCoros::getName() << " bump(" << n << ") -> " << updated << LL_ENDL; } /** @@ -82,7 +82,7 @@ public: */ void set(int n) { - LL_DEBUGS() << llcoro::logname() << " set(" << n << ")" << LL_ENDL; + LL_DEBUGS() << LLCoros::getName() << " set(" << n << ")" << LL_ENDL; mCond.set_all(n); } @@ -101,7 +101,7 @@ public: private: void yield_until(const char* func, int arg, int until) { - std::string name(llcoro::logname()); + std::string name(LLCoros::getName()); LL_DEBUGS() << name << " yield_until(" << until << ") suspending" << LL_ENDL; if (! mCond.wait_for_equal(mTimeout, until)) { -- cgit v1.2.3