Attempt to close LLEventCoro's LLBoundListener connection when promise has been fulfilled.
parent
a26905b0c5
commit
66abe4ccab
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* @date 2019-02
|
||||
* @brief LLCoprocedureManager unit test
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* $LicenseInfo:firstyear=2019&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue