- Library code update
- project update (added Eigen) git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -66,12 +66,17 @@ void MessageManager::deleteInstance()
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void MessageManager::MessageBase::post()
|
||||
bool MessageManager::MessageBase::post()
|
||||
{
|
||||
MessageManager* const mm = MessageManager::instance;
|
||||
|
||||
if (mm == nullptr || mm->quitMessagePosted || ! postMessageToSystemQueue (this))
|
||||
{
|
||||
Ptr deleter (this); // (this will delete messages that were just created with a 0 ref count)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -125,6 +130,25 @@ void MessageManager::stopDispatchLoop()
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_COMPILER_SUPPORTS_LAMBDAS
|
||||
struct AsyncFunction : private MessageManager::MessageBase
|
||||
{
|
||||
AsyncFunction (std::function<void(void)> f) : fn (f) { post(); }
|
||||
|
||||
private:
|
||||
std::function<void(void)> fn;
|
||||
void messageCallback() override { fn(); }
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncFunction)
|
||||
};
|
||||
|
||||
void MessageManager::callAsync (std::function<void(void)> f)
|
||||
{
|
||||
new AsyncFunction (f);
|
||||
}
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
class AsyncFunctionCallback : public MessageManager::MessageBase
|
||||
{
|
||||
@@ -158,9 +182,15 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* cons
|
||||
jassert (! currentThreadHasLockedMessageManager());
|
||||
|
||||
const ReferenceCountedObjectPtr<AsyncFunctionCallback> message (new AsyncFunctionCallback (func, parameter));
|
||||
message->post();
|
||||
message->finished.wait();
|
||||
return message->result;
|
||||
|
||||
if (message->post())
|
||||
{
|
||||
message->finished.wait();
|
||||
return message->result;
|
||||
}
|
||||
|
||||
jassertfalse; // the OS message queue failed to send the message!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -275,7 +305,12 @@ bool MessageManagerLock::attemptLock (Thread* const threadToCheck, ThreadPoolJob
|
||||
}
|
||||
|
||||
blockingMessage = new BlockingMessage();
|
||||
blockingMessage->post();
|
||||
|
||||
if (! blockingMessage->post())
|
||||
{
|
||||
blockingMessage = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (! blockingMessage->lockedEvent.wait (20))
|
||||
{
|
||||
@@ -334,5 +369,7 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI()
|
||||
}
|
||||
}
|
||||
|
||||
ScopedJuceInitialiser_GUI::ScopedJuceInitialiser_GUI() { initialiseJuce_GUI(); }
|
||||
ScopedJuceInitialiser_GUI::~ScopedJuceInitialiser_GUI() { shutdownJuce_GUI(); }
|
||||
static int numScopedInitInstances = 0;
|
||||
|
||||
ScopedJuceInitialiser_GUI::ScopedJuceInitialiser_GUI() { if (numScopedInitInstances++ == 0) initialiseJuce_GUI(); }
|
||||
ScopedJuceInitialiser_GUI::~ScopedJuceInitialiser_GUI() { if (--numScopedInitInstances == 0) shutdownJuce_GUI(); }
|
||||
|
||||
Reference in New Issue
Block a user