Public Member Functions | Static Public Member Functions

MessageManager Class Reference

Delivers Message objects to MessageListeners, and handles the event-dispatch loop. More...

List of all members.

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.
void * callFunctionOnMessageThread (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 setCurrentMessageThread().
bool currentThreadHasLockedMessageManager () const noexcept
 Returns true if the caller thread has currenltly 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 () noexcept
 Returns the global instance of the MessageManager.
static void broadcastMessage (const String &messageText)
 Sends a message to all other JUCE applications that are running.

Detailed Description

Delivers Message objects to MessageListeners, and handles the event-dispatch loop.

See also:
Message, MessageListener, MessageManagerLock, JUCEApplication

Member Function Documentation

static MessageManager* MessageManager::getInstance (  ) [static]

Returns the global instance of the MessageManager.

void 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
void 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
bool MessageManager::hasStopMessageBeenSent (  ) const

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

void* 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*) 
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
bool MessageManager::isThisTheMessageThread (  ) const

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

void 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
Thread::ThreadID MessageManager::getCurrentMessageThread (  ) const

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

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

See also:
setCurrentMessageThread
bool MessageManager::currentThreadHasLockedMessageManager (  ) const

Returns true if the caller thread has currenltly 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.

static void 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
void 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
void MessageManager::deregisterBroadcastListener ( ActionListener listener )

Deregisters a broadcast listener.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines