44class JUCE_API MessageManager final
82 #if JUCE_MODAL_LOOPS_PERMITTED
88 bool runDispatchLoopUntil (
int millisecondsToRunFor);
97 static bool callAsync (std::function<
void()> functionToCall);
117 void* callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* userData);
120 bool isThisTheMessageThread() const noexcept;
127 void setCurrentThreadAsMessageThread();
143 bool currentThreadHasLockedMessageManager() const noexcept;
148 static
bool existsAndIsLockedByCurrentThread() noexcept;
153 static
bool existsAndIsCurrentThread() noexcept;
184 MessageBase() =
default;
185 ~MessageBase()
override =
default;
187 virtual void messageCallback() = 0;
192 JUCE_DECLARE_NON_COPYABLE (MessageBase)
226 void enter()
const noexcept;
276 void exit()
const noexcept;
284 void abort()
const noexcept;
297 struct BlockingMessage;
300 bool exclusiveTryAcquire (
bool)
const noexcept;
301 bool tryAcquire (
bool)
const noexcept;
303 void setAcquired (
bool success)
const noexcept;
313 mutable std::mutex mutex;
315 mutable std::condition_variable condvar;
316 mutable bool abortWait =
false, acquired =
false;
322 void deliverBroadcastMessage (
const String&);
323 ~MessageManager() noexcept;
328 MessageManager() noexcept;
330 static MessageManager* instance;
334 friend class QuitMessage;
335 friend class MessageManagerLock;
338 Atomic<
int> quitMessagePosted { 0 }, quitMessageReceived { 0 };
339 Thread::ThreadID messageThreadId;
340 Atomic<Thread::ThreadID> threadWithLock;
341 mutable std::mutex messageThreadIdMutex;
343 static bool postMessageToSystemQueue (MessageBase*);
344 static void* exitModalLoopCallback (
void*);
345 static void doPlatformSpecificInitialisation();
346 static void doPlatformSpecificShutdown();
348 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MessageManager)