27 #ifndef THREAD_PAUSER_H
28 #define THREAD_PAUSER_H
71 THREADSTATE_RUN_REQUESTED,
84 THREADSTATE_RUN_READY,
113 THREADSTATE_PAUSE_REQUESTED,
130 THREADSTATE_PAUSE_READY
152 ThreadState m_threadState;
157 ThreadState m_threadStatePrevious;
162 bool m_threadStatePreviousOuter;
167 pthread_t m_threadStatePreviousThreadId;
173 bool m_ignoreThreadingProblems;
182 Predicate(tp.m_mutex),
186 virtual bool EvaluatePrecondition()
188 bool ret = m_threadPauser.m_threadState == THREADSTATE_PAUSED;
191 LOG.
Error(
"PAUSED precondition failed");
192 m_threadPauser.ReportThreadPauserStatus(Logger::ERROR);
197 virtual bool EvaluatePredicate()
199 return m_threadPauser.m_threadState == THREADSTATE_RUN_REQUESTED;
201 } m_stateIsRunRequested;
210 Predicate(tp.m_mutex),
214 virtual bool EvaluatePrecondition()
216 bool ret = m_threadPauser.m_threadState == THREADSTATE_RUN_READY;
219 LOG.
Error(
"RUN READY precondition failed");
220 m_threadPauser.ReportThreadPauserStatus(Logger::ERROR);
225 virtual bool EvaluatePredicate()
227 return m_threadPauser.m_threadState == THREADSTATE_RUNNING;
233 ThreadState GetStateBlockingInner()
235 return GetAdvanceStateInner(
false);
238 ThreadState AdvanceStateInner()
240 return GetAdvanceStateInner(
true);
243 ThreadState GetAdvanceStateInner(
bool innerReadyToAdvance) ;
245 ThreadState GetStateNonblocking() ;
285 m_ignoreThreadingProblems = value;
312 return GetStateNonblocking() == THREADSTATE_RUN_READY;
321 return GetStateNonblocking() == THREADSTATE_PAUSE_READY;
334 static const char * GetThreadStateName(ThreadState ts) ;
343 bool IsPauseRequested()
345 return GetStateNonblocking() == THREADSTATE_PAUSE_REQUESTED;
366 void WaitWhilePaused();
ThreadState AdvanceStateOuter(ThreadState fromState)
Definition: ThreadPauser.cpp:20
Level
Definition: Logger.h:52
~ThreadPauser()
Definition: ThreadPauser.cpp:16
Definition: ThreadPauser.h:140
void Error(const char *format,...)
Definition: Logger.h:259
bool IsPauseReady()
Definition: ThreadPauser.h:319
void Run()
Definition: ThreadPauser.h:301
ThreadPauser()
Definition: ThreadPauser.cpp:6
void RequestPause()
Definition: ThreadPauser.h:272
void Pause()
Definition: ThreadPauser.h:329
void SetIgnoreThreadingProblems(bool value)
Definition: ThreadPauser.h:283
bool IsRunReady()
Definition: ThreadPauser.h:310
void RequestRun()
Definition: ThreadPauser.h:292