30 class MessageManagerLock;
33 class ActionBroadcaster;
36 #if JUCE_MODULE_AVAILABLE_juce_opengl
42 using MessageCallbackFunction =
void* (
void* userData);
66 static void deleteInstance();
76 void runDispatchLoop();
85 void stopDispatchLoop();
91 #if JUCE_MODAL_LOOPS_PERMITTED || DOXYGEN
97 bool runDispatchLoopUntil (
int millisecondsToRunFor);
102 template <
typename FunctionType>
105 new AsyncCallInvoker<FunctionType> (functionToCall);
126 void* callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* userData);
129 bool isThisTheMessageThread() const noexcept;
136 void setCurrentThreadAsMessageThread();
143 Thread::ThreadID getCurrentMessageThread() const noexcept {
return messageThreadId; }
152 bool currentThreadHasLockedMessageManager() const noexcept;
157 static
bool existsAndIsLockedByCurrentThread() noexcept;
162 static
bool existsAndIsCurrentThread() noexcept;
171 static
void broadcastMessage (const
String& messageText);
196 virtual void messageCallback() = 0;
235 void enter()
const noexcept;
280 bool tryEnter()
const noexcept;
285 void exit()
const noexcept;
293 void abort()
const noexcept;
309 bool tryAcquire (
bool)
const noexcept;
310 void messageCallback()
const;
321 void deliverBroadcastMessage (
const String&);
333 friend class QuitMessage;
337 Atomic<
int> quitMessagePosted { 0 }, quitMessageReceived { 0 };
339 Atomic<Thread::ThreadID> threadWithLock;
341 static bool postMessageToSystemQueue (MessageBase*);
342 static void* exitModalLoopCallback (
void*);
343 static void doPlatformSpecificInitialisation();
344 static void doPlatformSpecificShutdown();
345 static bool dispatchNextMessageOnSystemQueue (
bool returnIfNoPendingMessages);
347 template <
typename FunctionType>
348 struct AsyncCallInvoker :
public MessageBase
350 AsyncCallInvoker (FunctionType f) : callback (f) { post(); }
351 void messageCallback()
override { callback(); }
352 FunctionType callback;
354 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncCallInvoker)
357 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MessageManager)
474 void exitSignalSent()
override;
485 #define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED \
486 jassert (juce::MessageManager::existsAndIsLockedByCurrentThread());
493 #define JUCE_ASSERT_MESSAGE_THREAD \
494 jassert (juce::MessageManager::existsAndIsCurrentThread());
499 #define JUCE_ASSERT_MESSAGE_MANAGER_EXISTS \
500 jassert (juce::MessageManager::getInstanceWithoutCreating() != nullptr);