22 #ifndef MCR_EXTRAS_MACRO_H_ 23 #define MCR_EXTRAS_MACRO_H_ 40 friend class MacroPrivate;
62 return reference<Macro>(dispPt->
receiver)();
68 return reference<Macro>(trigPt->
actor)();
72 bool sticky =
false,
unsigned int threadMax = 1,
76 inline Macro &operator =(
const Macro ©tron)
82 inline bool operator()()
89 typedef void (*propertyChanged)(
void *);
91 void *propertyReceiver =
nullptr;
92 propertyChanged blockingChanged =
nullptr;
93 propertyChanged enabledChanged =
nullptr;
94 propertyChanged interruptorChanged =
nullptr;
95 propertyChanged nameChanged =
nullptr;
96 propertyChanged stickyChanged =
nullptr;
97 propertyChanged threadMaxChanged =
nullptr;
99 propertyChanged activatorsChanged =
nullptr;
100 propertyChanged signalsChanged =
nullptr;
101 propertyChanged triggersChanged =
nullptr;
103 propertyChanged threadCountChanged =
nullptr;
104 propertyChanged queuedChanged =
nullptr;
106 inline void callProperty(propertyChanged propertyFn)
112 if (_queued > _threadMax)
115 propertyFn(propertyReceiver);
117 virtual inline void objectChanged()
121 callProperty(activatorsChanged);
122 callProperty(signalsChanged);
123 callProperty(triggersChanged);
124 callProperty(threadCountChanged);
125 callProperty(queuedChanged);
133 inline bool blocking()
const 137 void setBlocking(
bool val);
139 inline bool enabled()
const 141 return _interruptor != DISABLE;
143 void setEnabled(
bool val)
145 setInterruptor(val ? CONTINUE : DISABLE);
154 const char *name()
const;
155 void setName(
const char *val);
157 inline bool sticky()
const 161 void setSticky(
bool val);
163 inline unsigned int threadMax()
const 167 void setThreadMax(
unsigned int val);
169 void setActivators(
const Signal *array,
size_t count);
174 setActivators(&vals.front(), vals.size());
176 inline void clearActivators()
178 setActivators(NULL, 0);
182 void setSignals(
const Signal *array,
size_t count);
187 setSignals(&vals.front(), vals.size());
189 inline void clearSignals()
194 void setTriggers(
const Trigger *array,
size_t count);
199 setTriggers(&vals.front(), vals.size());
201 inline void clearTriggers()
203 setTriggers(NULL, 0);
207 inline int threadCount()
const 211 inline unsigned queued()
const 216 inline void clearAll()
224 virtual void start();
227 inline bool running()
231 virtual void copy(
const Macro ©tron);
240 trigger.
actor =
this;
241 trigger.
trigger = Macro::trigger;
245 void applyDispatch();
252 void removeDispatch();
255 void addDispatch(
Signal &sigPt);
257 void addDispatch(
Trigger &trigPt);
262 inline unsigned int decQueued()
266 callProperty(queuedChanged);
270 inline unsigned int incQueued()
272 if (_queued < _threadMax) {
274 callProperty(queuedChanged);
297 int waitThreadsChanged();
299 void notifyThreadsChanged();
307 unsigned int _threadCount;
308 unsigned int _threadMax;
309 unsigned int _queued;
311 MacroPrivate *_private;
314 void ctor(
bool blocking =
false,
bool sticky =
false,
unsigned int threadMax = 1);
316 void disableEverything();
324 void clearThreads(
Interrupt clearType,
bool stickyInterrupt);
328 inline void onCanPause()
330 if (interruptor() == PAUSE)
336 void onRunComplete();
#define mcr_throwif(condition, errorNumber)
void dequeue(Interrupt val)
void setSignals(const T &vals)
void setTriggers(const T &vals)
mcr_Trigger_receive_fnc trigger
C++ wrappers and extensions of C types.
Libmacro, by Jonathan Pelletier, New Paradigm Software. Alpha version.
void setActivators(const T &vals)