![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
#include <FXGUISignal.h>
Public Types | |
enum | { ID_IO_READ = 0, ID_LAST } |
Public Member Functions | |
FXGUISignal (FXApp *a, FXObject *tgt=NULL, FXSelector sel=0, void *ptr=NULL) | |
FXApp * | getApp () const |
void | setTarget (FXObject *t) |
FXObject * | getTarget () const |
void | setSelector (FXSelector sel) |
FXSelector | getSelector () const |
void | setData (void *ptr) |
void * | getData () const |
void | signal () |
virtual | ~FXGUISignal () |
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.
FX::FXGUISignal::FXGUISignal | ( | FXApp * | a, |
FXObject * | tgt = NULL , |
||
FXSelector | sel = 0 , |
||
void * | ptr = NULL |
||
) |
Constructor.
virtual FX::FXGUISignal::~FXGUISignal | ( | ) | [virtual] |
Destructor.
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.
![]() |