Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
FXMessageChannel manages a messaging channel between a worker thread and the main user-interface thread. More...
#include <FXMessageChannel.h>
Public Types | |
enum | { ID_IO_READ =1, ID_LAST } |
Public Member Functions | |
long | onMessage (FXObject *, FXSelector, void *) |
FXMessageChannel (FXApp *a) | |
Initialize message channel. More... | |
FXApp * | getApp () const |
Get application pointer. | |
FXbool | message (FXObject *tgt, FXSelector msg, const void *data=nullptr, FXint size=0) |
Send a message msg comprising of FXSEL(type,id) to a target tgt, and pass optional data of size bytes. More... | |
virtual | ~FXMessageChannel () |
Clean up message channel. More... | |
Public Member Functions inherited from FX::FXObject | |
const FXchar * | getClassName () const |
Get class name of some object. | |
FXbool | isMemberOf (const FXMetaClass *metaclass) const |
Check if object is member of metaclass. | |
virtual long | tryHandle (FXObject *sender, FXSelector sel, void *ptr) |
Try handle message safely, catching certain exceptions. | |
virtual long | onDefault (FXObject *, FXSelector, void *) |
Called for unhandled messages. | |
virtual void | save (FXStream &store) const |
Save object to stream. | |
virtual void | load (FXStream &store) |
Load object from stream. | |
virtual | ~FXObject () |
Virtual destructor. | |
Protected Attributes | |
FXInputHandle | h [3] |
FXMutex | m |
FXMessageChannel manages a messaging channel between a worker thread and the main user-interface thread.
When an FXMessageChannel is constructed, it automatically calls addInput() function to register itself as the message handler for the SEL_IO_READ message from FXApp. Likewise, when FXMessageChannel is destroyed, it calls removeInput() to remove itself as the message handler for the SEL_IO_READ message from FXApp. When a worker thread calls the message() API, the target and message, as well as optional message data, are written into the message channel. The main user-interface thread is awakened and subsequently dispatches to the onMessage handler of FXMessageChannel, which reads the target, selector, and optional message data from the channel and then dispatches to this target using the given selector. Thus, FXMessageChannel provides a worker thread with a way to asynchronously invoke any message handler in the context of the main user-interface thread. If the size of the optional data is zero, the message handler will be passed a NULL pointer. The maximum payload size passed with message() is 8192 bytes.
FX::FXMessageChannel::FXMessageChannel | ( | FXApp * | a | ) |
Initialize message channel.
Adds the message channel to FXApp's input watch set.
|
virtual |
Clean up message channel.
Removes the message channel from FXApp's input watch set.
FXbool FX::FXMessageChannel::message | ( | FXObject * | tgt, |
FXSelector | msg, | ||
const void * | data = nullptr , |
||
FXint | size = 0 |
||
) |
Send a message msg comprising of FXSEL(type,id) to a target tgt, and pass optional data of size bytes.
This asynchronously calls the indicated handler in the context of the main GUI thread's event loop. Up to 8192 bytes may be passed along.
Copyright © 1997-2022 Jeroen van der Zijp |