diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2019-12-10 10:56:24 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 19:24:25 -0400 |
commit | 39e7b48317e3f0fe37d7398099ab1e38b97963bf (patch) | |
tree | 7734474fcadf89bfeeea1dbc099ccc33b3716ef6 /indra/llcommon/llcoros.h | |
parent | 3cd2beb97ef0d368d47b0b7efd242b3c709d01af (diff) |
DRTVWR-476: Make llcoro::logname() distinguish different threads.
Actually, introduce static LLCoros::logname() and make the namespaced free
function an alias for that.
Because CoroData is a subclass of LLInstanceTracker with a key, every instance
requires a distinct key. That conflicts with our "getName() returns empty
string for default coroutine on thread" convention. Introduce a new CoroData
constructor, specifically for the default coroutine on each thread, that
initializes the getName() name to empty string while providing a distinct
"mainN" key. Make get_CoroData() use that new constructor for its thread_local
instance, passing an atomic<int> incremented each time we initialize one for a
new thread.
Then LLCoros::logname() returns either the getName() name or the key.
Diffstat (limited to 'indra/llcommon/llcoros.h')
-rw-r--r-- | indra/llcommon/llcoros.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 2e4cd8ccad..95859198d4 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -143,6 +143,13 @@ public: static std::string getName(); /** + * This variation returns a name suitable for log messages: the explicit + * name for an explicitly-launched coroutine, or "mainN" for the default + * coroutine on a thread. + */ + static std::string logname(); + + /** * For delayed initialization. To be clear, this will only affect * coroutines launched @em after this point. The underlying facility * provides no way to alter the stack size of any running coroutine. @@ -272,6 +279,7 @@ private: struct CoroData: public LLInstanceTracker<CoroData, std::string> { CoroData(const std::string& name); + CoroData(int n); // tweaked name of the current coroutine const std::string mName; @@ -292,12 +300,7 @@ namespace llcoro { inline -std::string logname() -{ - static std::string main("main"); - std::string name(LLCoros::getName()); - return name.empty()? main : name; -} +std::string logname() { return LLCoros::logname(); } } // llcoro |