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

FX::FXGUISignal Class Reference

An FXGUISignal manages a waitable object which is used to awaken the main user-interface thread from a worker thread. More...

#include <FXGUISignal.h>

Inheritance diagram for FX::FXGUISignal:

FX::FXObject

List of all members.

Public Types

enum  {
  ID_IO_READ = 0,
  ID_LAST
}

Public Member Functions

 FXGUISignal (FXApp *a, FXObject *tgt=NULL, FXSelector sel=0, void *ptr=NULL)
FXAppgetApp () const
void setTarget (FXObject *t)
FXObjectgetTarget () const
void setSelector (FXSelector sel)
FXSelector getSelector () const
void setData (void *ptr)
void * getData () const
void signal ()
virtual ~FXGUISignal ()


Detailed Description

An FXGUISignal manages a waitable object which is used to awaken the main user-interface thread from a worker thread.

When a FXGUISignal is constructed, it automatically calls addInput() function to register itself as the message handler for the SEL_IO_READ message from FXApp. Likewise, when FXGUISignal 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 signal() API, the waitable object managed by FXGUISignal is set to the signaled state, after which the worker thread continues execution immediately. Meanwhile, the main user-interface thread is awakened because one of its inputs has become signaled. It invokes the onSignal handler of FXGUISignal, which clears the waitable object's state and subsequently dispatches to the target of FXGUISignal through the SEL_IO_READ message. Thus, the SEL_IO_READ handler in FXGUISignal is executed in the context of the user-interface thread, allowing any user-interaction without blocking a worker thread. In a typical scenario, a worker thread updates some common data structure, then notifies the main user-interface thread (via the FXGUISignal) to update the user interface and perform some appropriate action.


Member Enumeration Documentation

anonymous enum

Enumerator:
ID_IO_READ 
ID_LAST 


Constructor & Destructor Documentation

FX::FXGUISignal::FXGUISignal ( FXApp a,
FXObject tgt = NULL,
FXSelector  sel = 0,
void *  ptr = NULL 
)

Constructor.

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

Destructor.


Member Function Documentation

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

Get application.

void FX::FXGUISignal::setTarget ( FXObject t  )  [inline]

Set the message target object.

FXObject* FX::FXGUISignal::getTarget (  )  const [inline]

Get the message target object, if any.

void FX::FXGUISignal::setSelector ( FXSelector  sel  )  [inline]

Set the message identifier.

FXSelector FX::FXGUISignal::getSelector (  )  const [inline]

Get the message identifier.

void FX::FXGUISignal::setData ( void *  ptr  )  [inline]

Set user data pointer.

void* FX::FXGUISignal::getData (  )  const [inline]

Get user data pointer.

void FX::FXGUISignal::signal (  ) 

Signal the event; this API may be called by the worker thread to send a message to the user-interface thread.

Copyright © 1997-2005 Jeroen van der Zijp