mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
MailBox: Only allocate a promise when we have a blocking call.
This commit is contained in:
parent
a70c8d6fea
commit
58a9c2f278
2 changed files with 7 additions and 3 deletions
|
@ -36,7 +36,8 @@ void CMailBox::SendCall(const FunctionType& function, bool waitForCompletion)
|
|||
|
||||
if(waitForCompletion)
|
||||
{
|
||||
future = message.promise.get_future();
|
||||
message.promise = std::make_unique<std::promise<void>>();
|
||||
future = message.promise->get_future();
|
||||
}
|
||||
|
||||
m_calls.push_back(std::move(message));
|
||||
|
@ -73,5 +74,8 @@ void CMailBox::ReceiveCall()
|
|||
m_calls.pop_front();
|
||||
}
|
||||
message.function();
|
||||
message.promise.set_value();
|
||||
if(message.promise)
|
||||
{
|
||||
message.promise->set_value();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ private:
|
|||
MESSAGE& operator=(const MESSAGE&) = delete;
|
||||
|
||||
FunctionType function;
|
||||
std::promise<void> promise;
|
||||
std::unique_ptr<std::promise<void>> promise;
|
||||
};
|
||||
|
||||
typedef std::deque<MESSAGE> FunctionCallQueue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue