|
|
@@ -33,10 +33,8 @@ public: |
|
|
|
owner.handleAsyncUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
Atomic<int> shouldDeliver;
|
|
|
|
|
|
|
|
private:
|
|
|
|
AsyncUpdater& owner;
|
|
|
|
Atomic<int> shouldDeliver;
|
|
|
|
|
|
|
|
JUCE_DECLARE_NON_COPYABLE (AsyncUpdaterMessage)
|
|
|
|
};
|
|
|
@@ -53,13 +51,19 @@ AsyncUpdater::~AsyncUpdater() |
|
|
|
// pending on the main event thread - that's pretty dodgy threading, as the callback could
|
|
|
|
// happen after this destructor has finished. You should either use a MessageManagerLock while
|
|
|
|
// deleting this object, or find some other way to avoid such a race condition.
|
|
|
|
jassert ((! isUpdatePending()) || MessageManager::getInstance()->currentThreadHasLockedMessageManager());
|
|
|
|
jassert ((! isUpdatePending())
|
|
|
|
|| MessageManager::getInstanceWithoutCreating() == nullptr
|
|
|
|
|| MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager());
|
|
|
|
|
|
|
|
activeMessage->shouldDeliver.set (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsyncUpdater::triggerAsyncUpdate()
|
|
|
|
{
|
|
|
|
// If you're calling this before (or after) the MessageManager is
|
|
|
|
// running, then you're not going to get any callbacks!
|
|
|
|
jassert (MessageManager::getInstanceWithoutCreating() != nullptr);
|
|
|
|
|
|
|
|
if (activeMessage->shouldDeliver.compareAndSetBool (1, 0))
|
|
|
|
if (! activeMessage->post())
|
|
|
|
cancelPendingUpdate(); // if the message queue fails, this avoids getting
|
|
|
|