1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Allow moving into AsyncCallInvoker

This commit is contained in:
reuk 2019-03-06 16:10:49 +00:00 committed by Tom Poole
parent e14a183886
commit 4a294eaa39

View file

@ -96,9 +96,9 @@ public:
//==============================================================================
/** Asynchronously invokes a function or C++11 lambda on the message thread. */
template <typename FunctionType>
static void callAsync (FunctionType functionToCall)
static void callAsync (FunctionType&& functionToCall)
{
new AsyncCallInvoker<FunctionType> (functionToCall);
new AsyncCallInvoker<FunctionType> (std::forward<FunctionType> (functionToCall));
}
/** Calls a function using the message-thread.
@ -343,8 +343,8 @@ private:
template <typename FunctionType>
struct AsyncCallInvoker : public MessageBase
{
AsyncCallInvoker (FunctionType f) : callback (f) { post(); }
void messageCallback() override { callback(); }
AsyncCallInvoker (FunctionType&& f) : callback (std::forward<FunctionType> (f)) { post(); }
void messageCallback() override { callback(); }
FunctionType callback;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncCallInvoker)