From 285613b892f41d0c72c03b8551dd003f61a5f2be Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 3 Jun 2009 21:38:21 +0000 Subject: DEV-32777: Introduce LLCoros, an LLSingleton registry of named coroutine instances. LLCoros::launch() intends to address three issues: - ownership of coroutine instance - cleanup of coroutine instance when it terminates - central place to twiddle MSVC optimizations to bypass DEV-32777 crash. Initially coded on Mac; will address the third bullet on Windows. Adapt listenerNameForCoro() to consult LLCoros::getName() if applicable. Change LLLogin::Impl::connect() to use LLCoros::launch(). LLCoros::getName() relies on patch to boost::coroutines::coroutine::self to introduce get_id(). --- indra/llcommon/lleventcoro.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lleventcoro.cpp') diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index cea5a1eda3..d598f1cc4a 100644 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -20,20 +20,31 @@ // other Linden headers #include "llsdserialize.h" #include "llerror.h" +#include "llcoros.h" -std::string LLEventDetail::listenerNameForCoro(const void* self) +std::string LLEventDetail::listenerNameForCoroImpl(const void* self_id) { + // First, if this coroutine was launched by LLCoros::launch(), find that name. + std::string name(LLCoros::instance().getNameByID(self_id)); + if (! name.empty()) + { + return name; + } + // Apparently this coroutine wasn't launched by LLCoros::launch(). Check + // whether we have a memo for this self_id. typedef std::map MapType; static MapType memo; - MapType::const_iterator found = memo.find(self); + MapType::const_iterator found = memo.find(self_id); if (found != memo.end()) { // this coroutine instance has called us before, reuse same name return found->second; } // this is the first time we've been called for this coroutine instance - std::string name(LLEventPump::inventName("coro")); - memo[self] = name; + name = LLEventPump::inventName("coro"); + memo[self_id] = name; + LL_INFOS("LLEventCoro") << "listenerNameForCoroImpl(" << self_id << "): inventing coro name '" + << name << "'" << LL_ENDL; return name; } -- cgit v1.2.3