diff options
author | Brad Kittenbrink <brad@lindenlab.com> | 2019-03-04 13:00:52 -0800 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 18:39:21 -0400 |
commit | 66abe4ccab7b60e9056ee03b9536b9980599d5f0 (patch) | |
tree | a22620e90200c3e9133eb90299c3d7a61f38dc5a /indra/llcommon | |
parent | a26905b0c5570644bb7a65b952accfe2c3f81c33 (diff) |
Attempt to close LLEventCoro's LLBoundListener connection when promise has been fulfilled.
Diffstat (limited to 'indra/llcommon')
-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 |