diff options
Diffstat (limited to 'indra/llcommon/lleventcoro.cpp')
-rw-r--r-- | indra/llcommon/lleventcoro.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 367ddf485d..aa9f4b7840 100644 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -134,12 +134,15 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName, // return the consuming attribute for some other coroutine, most likely // the main routine. bool consuming(LLCoros::get_consuming()); + + std::shared_ptr<LLBoundListener> connection_ptr = std::make_shared<LLBoundListener>(); + // make a callback that will assign a value to the future, and listen on // the specified LLEventPump with that callback - LLBoundListener connection( - replyPump.getPump().listen(listenerName, - [&promise, consuming, listenerName](const LLSD& result) + *connection_ptr = replyPump.getPump().listen(listenerName, + [&promise, consuming, listenerName, connection_ptr](const LLSD& result) { + connection_ptr->disconnect(); try { promise.set_value(result); @@ -150,7 +153,7 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName, << listenerName << "' " << ex.what() << LL_ENDL; } return consuming; - })); + }); // skip the "post" part if requestPump is default-constructed if (requestPump) { @@ -169,7 +172,7 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName, LL_DEBUGS("lleventcoro") << callerName << ": coroutine " << listenerName << " about to wait on LLEventPump " << replyPump.getPump().getName() << LL_ENDL; - return connection; + return *connection_ptr; } } // anonymous |