mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-20 01:14:20 +00:00
Renamed and shifted around a few native code files.
This commit is contained in:
parent
0a9cbd36c4
commit
9770806e09
27 changed files with 706 additions and 677 deletions
|
|
@ -395,26 +395,47 @@ void MessageManager::broadcastMessage (const String& value)
|
|||
/* TODO */
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class AsyncFunctionCaller : public AsyncUpdater
|
||||
{
|
||||
public:
|
||||
static void* call (MessageCallbackFunction* func_, void* parameter_)
|
||||
{
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread())
|
||||
return func_ (parameter_);
|
||||
|
||||
AsyncFunctionCaller caller (func_, parameter_);
|
||||
caller.triggerAsyncUpdate();
|
||||
caller.finished.wait();
|
||||
return caller.result;
|
||||
}
|
||||
|
||||
void handleAsyncUpdate()
|
||||
{
|
||||
result = (*func) (parameter);
|
||||
finished.signal();
|
||||
}
|
||||
|
||||
private:
|
||||
WaitableEvent finished;
|
||||
MessageCallbackFunction* func;
|
||||
void* parameter;
|
||||
void* volatile result;
|
||||
|
||||
AsyncFunctionCaller (MessageCallbackFunction* func_, void* parameter_)
|
||||
: result (0), func (func_), parameter (parameter_)
|
||||
{}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (AsyncFunctionCaller);
|
||||
};
|
||||
|
||||
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* func, void* parameter)
|
||||
{
|
||||
if (LinuxErrorHandling::errorOccurred)
|
||||
return 0;
|
||||
|
||||
if (isThisTheMessageThread())
|
||||
return func (parameter);
|
||||
|
||||
InternalMessageQueue::MessageThreadFuncCall messageCallContext;
|
||||
messageCallContext.func = func;
|
||||
messageCallContext.parameter = parameter;
|
||||
|
||||
InternalMessageQueue::getInstanceWithoutCreating()
|
||||
->postMessage (new Message (InternalMessageQueue::MessageThreadFuncCall::uniqueID,
|
||||
0, 0, &messageCallContext));
|
||||
|
||||
// Wait for it to complete before continuing
|
||||
messageCallContext.event.wait();
|
||||
|
||||
return messageCallContext.result;
|
||||
return AsyncFunctionCaller::call (func, parameter);
|
||||
}
|
||||
|
||||
// this function expects that it will NEVER be called simultaneously for two concurrent threads
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue