summaryrefslogtreecommitdiff
path: root/indra/llcommon/lleventcoro.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2009-06-03 21:38:21 +0000
committerNat Goodspeed <nat@lindenlab.com>2009-06-03 21:38:21 +0000
commit285613b892f41d0c72c03b8551dd003f61a5f2be (patch)
tree648299cef5fac0a373e5e3ba1e244d21ba34b42a /indra/llcommon/lleventcoro.cpp
parent7fe359b293db531e7ff82ef606cfa4c5c826b656 (diff)
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().
Diffstat (limited to 'indra/llcommon/lleventcoro.cpp')
-rw-r--r--indra/llcommon/lleventcoro.cpp19
1 files changed, 15 insertions, 4 deletions
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<const void*, std::string> 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;
}