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

FXEX::FXThreadEvent Class Reference

:Description. More...

#include <FXThreadEvent.h>

Inheritance diagram for FXEX::FXThreadEvent::

FXEX::FXBaseObject FXObject List of all members.

Public Methods

 FXThreadEvent (FXObject *tgt=NULL, FXSelector sel=0)
void signal ()
void signal (FXuint seltype)
virtual ~FXThreadEvent ()

Detailed Description

:Description.

Interthread communication object

------------------------------------------------------------------

Usage:

GUI_thread.h: ============

class MyGUI::FXWhatEver { // constructor MyGUI(...);

// message IDs enum { ID_THREAD_EVENT = FXWhatEver::ID_LAST, ID_LAST };

// message handler long onThreadEvent(FXObject*, FXSelector, void*);

// thread event object FXThreadEvent m_threadEvent; };

GUI_thread.cpp: ==============

// message map FXDEFMAP(MyGUI, FXWhatEver) = { FXMAPFUNC(SEL_THREAD_EVENT, MyGUI::ID_THREAD_EVENT, MyGUI::onThreadEvent) };

// constructor MyGUI::MyGUI(...) { m_threadEvent.setTarget(this), m_threadEvent.setSelector(ID_THREAD_EVENT); }

// message handler long onThreadEvent(FXObject*, FXSelector, void*) { do something with the GUI }

Worker_thread.cpp: =================

int threadFunction(...) { FXThreadEvent* pThreadEvent = (FXThreadEvent*)(ptr);

while (not_finished) { // work hard ...

// wake up GUI if (something_happened_and_the_GUI_needs_to_know_it) { pThreadEvent.signal(); } }

... }

Definition at line 103 of file FXThreadEvent.h.


Constructor & Destructor Documentation

FXEX::FXThreadEvent::FXThreadEvent FXObject * tgt = NULL,
FXSelector sel = 0
 

Construct an object capable of signaling the main FOX event loop.

virtual FXEX::FXThreadEvent::~FXThreadEvent [virtual]
 

destructor.


Member Function Documentation

void FXEX::FXThreadEvent::signal
 

Signal the event - using the SEL_THREAD FXSelector type.

This is meant to be called from the worker thread - it sends a mesage to the target, which is in another thread.

void FXEX::FXThreadEvent::signal FXuint seltype
 

Signal the event - using the specified FXSelector.

This is meant to be called from the worker thread - it sends a mesage to the target, which is in another thread.