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

FXReactor.h
1 /********************************************************************************
2 * *
3 * R e a c t o r C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXREACTOR_H
22 #define FXREACTOR_H
23 
24 namespace FX {
25 
26 
58 class FXAPI FXReactor {
59  friend class FXEventDispatcher;
60 private:
61  struct Internals;
62 private:
63  Internals *internals; // Internals
64  FXint sigreceived; // Most recent received signal
65  FXint numhandles; // Number of handles
66  FXint numwatched; // Number of watched
67  FXint numraised; // Number of raised handles
68  FXint current; // Current handle
69 private:
70  static FXReactor* volatile sigmanager[64];
71 private:
72  FXReactor(const FXReactor&);
73  FXReactor &operator=(const FXReactor&);
74 private:
75  static void CDECL signalhandler(FXint sig);
76  static void CDECL signalhandlerasync(FXint sig);
77 public:
78 
80  enum {
81  InputNone = 0,
82  InputRead = 1,
83  InputWrite = 2,
84  InputExcept = 4
85  };
86 
88  enum {
89  DispatchAll = 0xffffffff,
90  DispatchSignals = 0x00000001,
91  DispatchTimers = 0x00000002,
92  DispatchIdle = 0x00000004,
93  DispatchEvents = 0x00000008,
94  DispatchOther = 0x00000010
95  };
96 
98  static const FXTime maxwait;
99 
100 public:
101 
103  FXReactor();
104 
106  virtual FXbool init();
107 
109  FXbool isInitialized() const { return (internals!=nullptr); }
110 
114  virtual FXbool dispatch(FXTime blocking=forever,FXuint flags=DispatchAll);
115 
117  virtual FXbool addHandle(FXInputHandle hnd,FXuint mode=InputRead);
118 
120  virtual FXbool remHandle(FXInputHandle hnd);
121 
124  virtual FXbool dispatchHandle(FXInputHandle hnd,FXuint mode,FXuint flags);
125 
127  virtual FXbool addSignal(FXint sig,FXbool=false);
128 
130  virtual FXbool remSignal(FXint sig);
131 
133  virtual FXbool hasSignal(FXint sig) const;
134 
136  virtual FXbool dispatchSignal(FXint sig);
137 
140  virtual FXTime nextTimeout();
141 
143  virtual FXbool dispatchTimeout(FXTime due);
144 
146  virtual FXbool dispatchIdle();
147 
149  virtual FXbool exit();
150 
152  virtual ~FXReactor();
153  };
154 
155 }
156 
157 #endif
FXbool isInitialized() const
Is reactor initialized.
Definition: FXReactor.h:109
Definition: FX4Splitter.h:28
A FXEventDispatcher extends FXDispatcher, adding graphical user interface handling and other display-...
Definition: FXEventDispatcher.h:22
FXReactor implements the reactor pattern.
Definition: FXReactor.h:58
static const FXTime maxwait
Sleep no longer than this.
Definition: FXReactor.h:98

Copyright © 1997-2022 Jeroen van der Zijp