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

 FXMessageChannel (FXApp *a)
FXAppgetApp () const
FXbool message (FXObject *tgt, FXSelector msg, const void *data=NULL, FXint size=0)
virtual ~FXMessageChannel ()


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.


Member Enumeration Documentation

anonymous enum

Enumerator:
ID_IO_READ 
ID_LAST 


Constructor & Destructor Documentation

FX::FXMessageChannel::FXMessageChannel ( FXApp a  ) 

Initialize message channel.

virtual FX::FXMessageChannel::~FXMessageChannel (  )  [virtual]

Clean up message channel.


Member Function Documentation

FXApp* FX::FXMessageChannel::getApp (  )  const [inline]

Get application pointer.

FXbool FX::FXMessageChannel::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.

Copyright © 1997-2009 Jeroen van der Zijp