Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXMessageChannel Class Reference

FXMessageChannel manages a messaging channel between a worker thread and the main user-interface thread. More...

#include <FXMessageChannel.h>

Inheritance diagram for FX::FXMessageChannel:
FX::FXObject

List of all members.

Public Types

enum  { ID_IO_READ = 1, ID_LAST }

Public Member Functions

long onMessage (FXObject *, FXSelector, void *)
 FXMessageChannel (FXApp *a)
 Initialize message channel.
FXAppgetApp () const
 Get application pointer.
FXbool message (FXObject *tgt, FXSelector msg, const void *data=NULL, FXint size=0)
 Send a message msg comprising of FXSEL(type,id) to a target tgt, and pass optional data of size bytes.
virtual ~FXMessageChannel ()
 Clean up message channel.
- 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

Detailed Description

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 documentation for this class was generated from the following file:

Copyright © 1997-2016 Jeroen van der Zijp