24 #ifndef _LIBS_BASEAPP_THREAD_MANAGER_H_ 25 #define _LIBS_BASEAPP_THREAD_MANAGER_H_ 27 #include <aspect/blocked_timing.h> 28 #include <aspect/blocked_timing/executor.h> 29 #include <core/exception.h> 30 #include <core/threading/thread_collector.h> 31 #include <core/threading/thread_list.h> 32 #include <core/utils/lock_map.h> 39 class ThreadInitializer;
40 class ThreadFinalizer;
54 add_maybelocked(tl,
true);
60 add_maybelocked(t,
true);
66 remove_maybelocked(tl,
true);
72 remove_maybelocked(t,
true);
80 virtual void try_recover(std::list<std::string> &recovered_threads);
89 void internal_add_thread(
Thread *t);
90 void internal_remove_thread(
Thread *t);
91 void add_maybelocked(
ThreadList &tl,
bool lock);
92 void add_maybelocked(
Thread *t,
bool lock);
93 void remove_maybelocked(
ThreadList &tl,
bool lock);
94 void remove_maybelocked(
Thread *t,
bool lock);
115 ThreadInitializer *initializer_;
116 ThreadFinalizer * finalizer_;
118 LockMap<BlockedTimingAspect::WakeupHook, ThreadList> threads_;
119 LockMap<BlockedTimingAspect::WakeupHook, ThreadList>::iterator tit_;
121 ThreadList untimed_threads_;
122 WaitCondition *waitcond_timedthreads_;
124 ThreadManagerAspectCollector *aspect_collector_;
125 bool interrupt_timed_thread_wait_;
void set_inifin(ThreadInitializer *initializer, ThreadFinalizer *finalizer)
Set initializer/finalizer.
virtual void add(ThreadList &tl)
Add multiple threads.
Fawkes library namespace.
virtual void remove(ThreadList &tl)
Remove multiple threads.
virtual ~ThreadManager()
Destructor.
virtual bool timed_threads_exist()
Check if any timed threads exist.
Thread class encapsulation of pthreads.
virtual void force_remove(ThreadList &tl)
Force removal of the given threads.
ThreadManager()
Constructor.
virtual void wait_for_timed_threads()
Wait for timed threads.
Base application thread manager.
WakeupHook
Type to define at which hook the thread is woken up.
Thread initializer interface.
virtual void add(Thread *t)
Add single thread.
virtual void wakeup(BlockedTimingAspect::WakeupHook hook, Barrier *barrier=0)
Wakeup thread for given hook.
virtual void wakeup_and_wait(BlockedTimingAspect::WakeupHook hook, unsigned int timeout_usec=0)
Wakeup thread for given hook and wait for completion.
virtual void interrupt_timed_thread_wait()
Interrupt any currently running wait_for_timed_threads() and cause it to throw an InterruptedExceptio...
virtual void remove(Thread *t)
Remove single thread.
virtual void try_recover(std::list< std::string > &recovered_threads)
Try to recover threads.
ThreadCollector * aspect_collector() const
Get a thread collector to be used for an aspect initializer.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
Thread finalizer interface.