JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
juce::MessageManager Class Referencefinal

This class is in charge of the application's event-dispatch loop. More...

#include "juce_MessageManager.h"

Classes

class  Lock
 A lock you can use to lock the message manager. More...
 
class  MessageBase
 Internal class used as the base class for all message objects. More...
 
class  QuitMessage
 

Public Member Functions

void runDispatchLoop ()
 Runs the event dispatch loop until a stop message is posted.
 
void stopDispatchLoop ()
 Sends a signal that the dispatch loop should terminate.
 
bool hasStopMessageBeenSent () const noexcept
 Returns true if the stopDispatchLoop() method has been called.
 
voidcallFunctionOnMessageThread (MessageCallbackFunction *callback, void *userData)
 Calls a function using the message-thread.
 
bool isThisTheMessageThread () const noexcept
 Returns true if the caller-thread is the message thread.
 
void setCurrentThreadAsMessageThread ()
 Called to tell the manager that the current thread is the one that's running the dispatch loop.
 
Thread::ThreadID getCurrentMessageThread () const noexcept
 Returns the ID of the current message thread, as set by setCurrentThreadAsMessageThread().
 
bool currentThreadHasLockedMessageManager () const noexcept
 Returns true if the caller thread has currently got the message manager locked.
 
void registerBroadcastListener (ActionListener *listener)
 Registers a listener to get told about broadcast messages.
 
void deregisterBroadcastListener (ActionListener *listener)
 Deregisters a broadcast listener.
 

Static Public Member Functions

static MessageManagergetInstance ()
 Returns the global instance of the MessageManager.
 
static MessageManagergetInstanceWithoutCreating () noexcept
 Returns the global instance of the MessageManager, or nullptr if it doesn't exist.
 
static void deleteInstance ()
 Deletes the global MessageManager instance.
 
static bool callAsync (std::function< void()> functionToCall)
 Asynchronously invokes a function or C++11 lambda on the message thread.
 
static bool existsAndIsLockedByCurrentThread () noexcept
 Returns true if there's an instance of the MessageManager, and if the current thread has the lock on it.
 
static bool existsAndIsCurrentThread () noexcept
 Returns true if there's an instance of the MessageManager, and if the current thread is running it.
 
static void broadcastMessage (const String &messageText)
 Sends a message to all other JUCE applications that are running.
 

Friends

class MessageBase
 
class QuitMessage
 
class MessageManagerLock
 

Detailed Description

This class is in charge of the application's event-dispatch loop.

See also
Message, CallbackMessage, MessageManagerLock, JUCEApplication, JUCEApplicationBase

@tags{Events}

Definition at line 44 of file juce_MessageManager.h.

Member Function Documentation

◆ broadcastMessage()

void juce::MessageManager::broadcastMessage ( const String messageText)
static

Sends a message to all other JUCE applications that are running.

Parameters
messageTextthe string that will be passed to the actionListenerCallback() method of the broadcast listeners in the other app.
See also
registerBroadcastListener, ActionListener

Definition at line 325 of file juce_Messaging_linux.cpp.

◆ callAsync()

bool juce::MessageManager::callAsync ( std::function< void()>  functionToCall)
static

Asynchronously invokes a function or C++11 lambda on the message thread.

Returns
true if the message was successfully posted to the message queue, or false otherwise.

Definition at line 195 of file juce_MessageManager.cpp.

◆ callFunctionOnMessageThread()

void * juce::MessageManager::callFunctionOnMessageThread ( MessageCallbackFunction callback,
void userData 
)

Calls a function using the message-thread.

This can be used by any thread to cause this function to be called-back by the message thread. If it's the message-thread that's calling this method, then the function will just be called; if another thread is calling, a message will be posted to the queue, and this method will block until that message is delivered, the function is called, and the result is returned.

Be careful not to cause any deadlocks with this! It's easy to do - e.g. if the caller thread has a critical section locked, which an unrelated message callback then tries to lock before the message thread gets round to processing this callback.

Parameters
callbackthe function to call - its signature must be
void* myCallbackFunction (void*)
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
userDataa user-defined pointer that will be passed to the function that gets called
Returns
the value that the callback function returns.
See also
MessageManagerLock

Definition at line 175 of file juce_MessageManager.cpp.

◆ currentThreadHasLockedMessageManager()

bool juce::MessageManager::currentThreadHasLockedMessageManager ( ) const
noexcept

Returns true if the caller thread has currently got the message manager locked.

see the MessageManagerLock class for more info about this.

This will be true if the caller is the message thread, because that automatically gains a lock while a message is being dispatched.

Definition at line 252 of file juce_MessageManager.cpp.

◆ deleteInstance()

void juce::MessageManager::deleteInstance ( )
static

Deletes the global MessageManager instance.

Does nothing if no instance had been created.

Definition at line 63 of file juce_MessageManager.cpp.

◆ deregisterBroadcastListener()

void juce::MessageManager::deregisterBroadcastListener ( ActionListener listener)

Deregisters a broadcast listener.

Definition at line 222 of file juce_MessageManager.cpp.

◆ existsAndIsCurrentThread()

bool juce::MessageManager::existsAndIsCurrentThread ( )
staticnoexcept

Returns true if there's an instance of the MessageManager, and if the current thread is running it.

Definition at line 266 of file juce_MessageManager.cpp.

◆ existsAndIsLockedByCurrentThread()

bool juce::MessageManager::existsAndIsLockedByCurrentThread ( )
staticnoexcept

Returns true if there's an instance of the MessageManager, and if the current thread has the lock on it.

Definition at line 258 of file juce_MessageManager.cpp.

◆ getCurrentMessageThread()

Thread::ThreadID juce::MessageManager::getCurrentMessageThread ( ) const
noexcept

Returns the ID of the current message thread, as set by setCurrentThreadAsMessageThread().

(Best to ignore this method unless you really know what you're doing..)

See also
setCurrentThreadAsMessageThread

Definition at line 134 of file juce_MessageManager.h.

◆ getInstance()

MessageManager * juce::MessageManager::getInstance ( )
static

Returns the global instance of the MessageManager.

Definition at line 47 of file juce_MessageManager.cpp.

◆ getInstanceWithoutCreating()

MessageManager * juce::MessageManager::getInstanceWithoutCreating ( )
staticnoexcept

Returns the global instance of the MessageManager, or nullptr if it doesn't exist.

Definition at line 58 of file juce_MessageManager.cpp.

◆ hasStopMessageBeenSent()

bool juce::MessageManager::hasStopMessageBeenSent ( ) const
noexcept

Returns true if the stopDispatchLoop() method has been called.

Definition at line 80 of file juce_MessageManager.h.

◆ isThisTheMessageThread()

bool juce::MessageManager::isThisTheMessageThread ( ) const
noexcept

Returns true if the caller-thread is the message thread.

Definition at line 229 of file juce_MessageManager.cpp.

◆ registerBroadcastListener()

void juce::MessageManager::registerBroadcastListener ( ActionListener listener)

Registers a listener to get told about broadcast messages.

The actionListenerCallback() callback's string parameter is the message passed into broadcastMessage().

See also
broadcastMessage

Definition at line 214 of file juce_MessageManager.cpp.

◆ runDispatchLoop()

void juce::MessageManager::runDispatchLoop ( )

Runs the event dispatch loop until a stop message is posted.

This method is only intended to be run by the application's startup routine, as it blocks, and will only return after the stopDispatchLoop() method has been used.

See also
stopDispatchLoop

Definition at line 104 of file juce_MessageManager.cpp.

◆ setCurrentThreadAsMessageThread()

void juce::MessageManager::setCurrentThreadAsMessageThread ( )

Called to tell the manager that the current thread is the one that's running the dispatch loop.

(Best to ignore this method unless you really know what you're doing..)

See also
getCurrentMessageThread

Definition at line 236 of file juce_MessageManager.cpp.

◆ stopDispatchLoop()

void juce::MessageManager::stopDispatchLoop ( )

Sends a signal that the dispatch loop should terminate.

After this is called, the runDispatchLoop() or runDispatchLoopUntil() methods will be interrupted and will return.

See also
runDispatchLoop

Definition at line 119 of file juce_MessageManager.cpp.

Friends And Related Symbol Documentation

◆ MessageBase

friend class MessageBase
friend

Definition at line 332 of file juce_MessageManager.h.

◆ MessageManagerLock

friend class MessageManagerLock
friend

Definition at line 335 of file juce_MessageManager.h.

◆ QuitMessage

friend class QuitMessage
friend

Definition at line 334 of file juce_MessageManager.h.


The documentation for this class was generated from the following files: