Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
FXReactor implements the reactor pattern. More...
#include <FXReactor.h>
Public Types | |
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 | |
FXReactor () | |
Construct reactor. | |
virtual FXbool | init () |
Initialize 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 | addHandle (FXInputHandle hnd, FXuint mode=InputRead) |
Add new handle hnd to watch-list. | |
virtual FXbool | remHandle (FXInputHandle hnd) |
Remove handle hnd from watch-list. | |
virtual FXbool | dispatchHandle (FXInputHandle hnd, FXuint mode, FXuint flags) |
Dispatch handler for handle hnd. More... | |
virtual FXbool | addSignal (FXint sig, FXbool=false) |
Add (optionally asynchronous) signal sig to signal-set. | |
virtual FXbool | remSignal (FXint sig) |
Remove signal sig from signal-set. | |
virtual FXbool | hasSignal (FXint sig) const |
Return true if signal sig is handled by this dispatcher. | |
virtual FXbool | dispatchSignal (FXint sig) |
Dispatch when a signal was fired; return true when handled. | |
virtual FXTime | nextTimeout () |
Return time when first timer callback is due; the special value forever is returned when no timer is in effect. More... | |
virtual FXbool | dispatchTimeout (FXTime due) |
Dispatch when timeout expires; return true when handled. | |
virtual FXbool | dispatchIdle () |
Dispatch when idle; return true when handled. | |
virtual FXbool | exit () |
Exit reactor. | |
virtual | ~FXReactor () |
Destroy reactor object. | |
Static Public Attributes | |
static const FXTime | maxwait |
Sleep no longer than this. | |
Friends | |
class | FXEventDispatcher |
FXReactor implements the reactor pattern.
Given a list of file descriptors (handles), calling thread is blocked until any of the following happens:
Depending on what occurred, FXReactor dispatches to one of the handling API's: dispatchHandle(), dispatchTimeout(), or dispatchSignal(). Prior to blocking, if nothing demands immediate attention, the special handler dispatchIdle() is called.
If dispatchHandle(), dispatchTimeout(), dispatchSignal() or dispatchIdle() returned true, FXReactor will return with true; otherwise, it will continue to loop, decreasing the initial blocking time until eventually returning false when nothing happened during the entire blocking interval.
Each FXReactor can manage a set of signals, but note that only one single FXReactor is allowed to manage a particular signal; other signals may be left unassigned, or managed by other FXReactors.
If waiting for a very long but finite amount of time, FXReactor will wake up after at most FXReactor::maxwait, which is about 1 day. It will continue to loop and wait for additional intervals, decreasing the initial blocking time until eventually returning false when nothing happened.
anonymous enum |
anonymous enum |
|
virtual |
Dispatch if something happens within given blocking time.
Flags control subsets of events to be dispatched (signals, timers, idle, and more). Default is to dispatch all events.
Reimplemented in FX::FXEventDispatcher.
|
virtual |
Dispatch handler for handle hnd.
Return true if the callback returned true.
Reimplemented in FX::FXDispatcher.
|
virtual |
Return time when first timer callback is due; the special value forever is returned when no timer is in effect.
Reimplemented in FX::FXDispatcher.
Copyright © 1997-2022 Jeroen van der Zijp |