30class MessageManagerLock;
33class ActionBroadcaster;
36#if JUCE_MODULE_AVAILABLE_juce_opengl
42using MessageCallbackFunction =
void* (
void* userData);
66 static void deleteInstance();
91 #if JUCE_MODAL_LOOPS_PERMITTED || DOXYGEN
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 };
338 Thread::ThreadID messageThreadId;
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);
Manages a list of ActionListeners, and can send them messages.
Interface class for delivery of events that are sent by an ActionBroadcaster.
Automatically locks and unlocks a mutex object.
Automatically locks and unlocks a mutex object.
Automatically unlocks and re-locks a mutex object.
Used to make sure that the calling thread has exclusive access to the message loop.
bool lockWasGained() const noexcept
Returns true if the lock was successfully acquired.
A lock you can use to lock the message manager.
Internal class used as the base class for all message objects.
This class is in charge of the application's event-dispatch loop.
bool runDispatchLoopUntil(int millisecondsToRunFor)
Synchronously dispatches messages until a given time has elapsed.
void runDispatchLoop()
Runs the event dispatch loop until a stop message is posted.
bool hasStopMessageBeenSent() const noexcept
Returns true if the stopDispatchLoop() method has been called.
void stopDispatchLoop()
Sends a signal that the dispatch loop should terminate.
static void callAsync(FunctionType functionToCall)
Asynchronously invokes a function or C++11 lambda on the message thread.
A smart-pointer class which points to a reference-counted object.
A base class which provides methods for reference-counting.
A task that is executed by a ThreadPool object.
Used to receive callbacks for thread exit calls.
Allows threads to wait for events triggered by other threads.
#define JUCE_API
This macro is added to all JUCE public class declarations.
A simple wrapper around std::atomic.