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

FX::FXDispatcher Class Reference

A FXDispatcher watches a number of devices and signals for activity and dispatches to the proper function when activity is observed. More...

#include <FXDispatcher.h>

Inheritance diagram for FX::FXDispatcher:
FX::FXReactor FX::FXEventDispatcher

Public Types

typedef FXCallback< FXbool(FXDispatcher *, FXInputHandle, FXuint, void *)> HandleCallback
 I/O Handle callback when a handle is raised.
 
typedef FXCallback< FXbool(FXDispatcher *, FXint, void *)> SignalCallback
 Signal callback when signal has been fired.
 
typedef FXCallback< FXbool(FXDispatcher *, FXTime, void *)> TimeoutCallback
 Timer callback when timer expired.
 
typedef FXCallback< FXbool(FXDispatcher *, void *)> IdleCallback
 Idle callback when dispatcher is about to block.
 
- Public Types inherited from FX::FXReactor
enum  { InputNone = 0, InputRead = 1, InputWrite = 2, InputExcept = 4 }
 Modes. More...
 
enum  {
  DispatchAll = 0xffffffff, DispatchSignals = 0x00000001, DispatchTimers = 0x00000002, DispatchIdle = 0x00000004,
  DispatchEvents = 0x00000008, DispatchOther = 0x00000010
}
 Dispatch flags. More...
 

Public Member Functions

 FXDispatcher ()
 Construct dispatcher object.
 
virtual FXbool init ()
 Initialize dispatcher.
 
virtual FXbool addHandle (HandleCallback cb, FXInputHandle hnd, FXuint mode=InputRead, void *ptr=NULL)
 Add callback cb with new handle hnd to watch-list.
 
virtual FXbool addHandle (FXInputHandle hnd, FXuint mode=InputRead)
 Add new handle hnd to watch-list (no callback)
 
virtual FXbool remHandle (FXInputHandle hnd)
 Remove handle hnd from watch-list.
 
virtual FXbool hasHandle (FXInputHandle hnd) const
 Return true if handle has been set.
 
virtual FXbool dispatchHandle (FXInputHandle hnd, FXuint mode, FXuint flags)
 Dispatch handler when handle index is raised. More...
 
virtual FXbool addSignal (SignalCallback cb, FXint sig, void *ptr=NULL, FXbool async=false)
 Add (optionally asynchronous) callback cb for signal sig to signal-set.
 
virtual FXbool addSignal (FXint sig, FXbool async=false)
 Add (optionally asynchronous) signal sig to signal-set (no callback)
 
virtual FXbool remSignal (FXint sig)
 Remove signal from signal-set.
 
virtual FXbool dispatchSignal (FXint sig)
 Dispatch a signal handler if signal fired. More...
 
virtual void * addTimeout (TimeoutCallback cb, FXTime due, void *ptr=NULL)
 Add timeout callback cb at time due (ns since Epoch). More...
 
virtual void * addInterval (TimeoutCallback cb, FXTime interval, void *ptr=NULL)
 Add timeout callback cb after time interval (ns). More...
 
virtual void * remTimeout (TimeoutCallback cb)
 Remove timeout callback cb. More...
 
virtual FXTime getTimeout (TimeoutCallback cb) const
 Return when timeout callback cb is due. More...
 
virtual FXbool hasTimeout (TimeoutCallback cb) const
 Return true if timeout callback cb been set.
 
virtual FXTime nextTimeout ()
 Return time when first timer callback is due. More...
 
virtual FXbool dispatchTimeout (FXTime due)
 Dispatch a timer when due. More...
 
virtual void * addIdle (IdleCallback cb, void *ptr=NULL)
 Add idle callback be executed when dispatch about to block. More...
 
virtual void * remIdle (IdleCallback cb)
 Remove idle callback cb. More...
 
virtual FXbool hasIdle (IdleCallback cb) const
 Return true if idle callback cb been set.
 
virtual FXbool dispatchIdle ()
 Dispatch one idle callback. More...
 
virtual FXbool exit ()
 Exit dispatcher.
 
virtual ~FXDispatcher ()
 Destroy dispatcher object.
 
- Public Member Functions inherited from FX::FXReactor
 FXReactor ()
 Construct reactor.
 
FXbool isInitialized () const
 Is reactor initialized.
 
virtual FXbool dispatch (FXTime blocking=forever, FXuint flags=DispatchAll)
 Dispatch if something happens within given blocking time. More...
 
virtual FXbool hasSignal (FXint sig) const
 Return true if signal sig is handled by this dispatcher.
 
virtual ~FXReactor ()
 Destroy reactor object.
 

Additional Inherited Members

- Static Public Attributes inherited from FX::FXReactor
static const FXTime maxwait
 Sleep no longer than this.
 

Detailed Description

A FXDispatcher watches a number of devices and signals for activity and dispatches to the proper function when activity is observed.

Member Function Documentation

◆ addIdle()

virtual void* FX::FXDispatcher::addIdle ( IdleCallback  cb,
void *  ptr = NULL 
)
virtual

Add idle callback be executed when dispatch about to block.

If callback cb was already set, remove it and return its old data pointer, then reset the callback with the new pointer.

◆ addInterval()

virtual void* FX::FXDispatcher::addInterval ( TimeoutCallback  cb,
FXTime  interval,
void *  ptr = NULL 
)
virtual

Add timeout callback cb after time interval (ns).

If callback cb was already set, remove it and return its old data pointer, then reset it to the new time and data pointer.

◆ addTimeout()

virtual void* FX::FXDispatcher::addTimeout ( TimeoutCallback  cb,
FXTime  due,
void *  ptr = NULL 
)
virtual

Add timeout callback cb at time due (ns since Epoch).

If callback cb was already set, remove it and return its old data pointer, then reset it to the new time and data pointer.

◆ dispatchHandle()

virtual FXbool FX::FXDispatcher::dispatchHandle ( FXInputHandle  hnd,
FXuint  mode,
FXuint  flags 
)
virtual

Dispatch handler when handle index is raised.

Return true if the handle was raised and the callback returned true.

Reimplemented from FX::FXReactor.

◆ dispatchIdle()

virtual FXbool FX::FXDispatcher::dispatchIdle ( )
virtual

Dispatch one idle callback.

Return true if a chore was set and the callback returned true.

Reimplemented from FX::FXReactor.

◆ dispatchSignal()

virtual FXbool FX::FXDispatcher::dispatchSignal ( FXint  sig)
virtual

Dispatch a signal handler if signal fired.

Return true if the signal was raised and the callback handler returned true.

Reimplemented from FX::FXReactor.

◆ dispatchTimeout()

virtual FXbool FX::FXDispatcher::dispatchTimeout ( FXTime  due)
virtual

Dispatch a timer when due.

Return true if a timer was due and the callback returned true.

Reimplemented from FX::FXReactor.

◆ getTimeout()

virtual FXTime FX::FXDispatcher::getTimeout ( TimeoutCallback  cb) const
virtual

Return when timeout callback cb is due.

If callback cb was not set or has expired, return forever.

◆ nextTimeout()

virtual FXTime FX::FXDispatcher::nextTimeout ( )
virtual

Return time when first timer callback is due.

If no timeout callback is currently set, return forever.

Reimplemented from FX::FXReactor.

◆ remIdle()

virtual void* FX::FXDispatcher::remIdle ( IdleCallback  cb)
virtual

Remove idle callback cb.

If callback cb was set, return its data pointer.

◆ remTimeout()

virtual void* FX::FXDispatcher::remTimeout ( TimeoutCallback  cb)
virtual

Remove timeout callback cb.

If callback cb was set, return its data pointer.


The documentation for this class was generated from the following file:

Copyright © 1997-2020 Jeroen van der Zijp