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.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/lleventcoro.h') diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index 5726ea0f65..c6d9de171d 100644 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -106,7 +106,14 @@ namespace LLEventDetail * that's okay, since it won't collide with any listener name used by the * earlier coroutine since that earlier coroutine no longer exists. */ - LL_COMMON_API std::string listenerNameForCoro(const void* self); + template + std::string listenerNameForCoro(COROUTINE_SELF& self) + { + return listenerNameForCoroImpl(self.get_id()); + } + + /// Implementation for listenerNameForCoro() + LL_COMMON_API std::string listenerNameForCoroImpl(const void* self_id); /** * Implement behavior described for postAndWait()'s @a replyPumpNamePath @@ -185,7 +192,7 @@ LLSD postAndWait(SELF& self, const LLSD& event, const LLEventPumpOrPumpName& req boost::coroutines::future future(self); // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback - std::string listenerName(LLEventDetail::listenerNameForCoro(&self)); + std::string listenerName(LLEventDetail::listenerNameForCoro(self)); LLTempBoundListener connection( replyPump.getPump().listen(listenerName, voidlistener(boost::coroutines::make_callback(future)))); @@ -307,7 +314,7 @@ LLEventWithID postAndWait2(SELF& self, const LLSD& event, boost::coroutines::future future(self); // either callback will assign a value to this future; listen on // each specified LLEventPump with a callback - std::string name(LLEventDetail::listenerNameForCoro(&self)); + std::string name(LLEventDetail::listenerNameForCoro(self)); LLTempBoundListener connection0( replyPump0.getPump().listen(name + "a", LLEventDetail::wfeoh(boost::coroutines::make_callback(future), 0))); -- cgit v1.2.3