24 #ifndef __CORE_THREADING_THREAD_LIST_H_
25 #define __CORE_THREADING_THREAD_LIST_H_
27 #include <core/exception.h>
28 #include <core/threading/thread.h>
29 #include <core/threading/thread_initializer.h>
30 #include <core/threading/thread_finalizer.h>
31 #include <core/utils/lock_list.h>
42 class InterruptibleBarrier;
61 ThreadList(
bool maintain_barrier,
const char *tlname =
"");
66 void set_name(
const char *format, ...);
82 unsigned int timeout_nanosec = 0);
88 void try_recover(std::list<std::string> &recovered_threads);
100 ThreadList::iterator
erase(iterator pos);
102 void remove(
Thread *thread);
120 void notify_of_failed_init();
121 void update_barrier();
126 Mutex *__finalize_mutex;
129 std::list<std::pair<InterruptibleBarrier *, ThreadList> > __wnw_bad_barriers;
130 std::list<std::pair<InterruptibleBarrier *, ThreadList> >::iterator __wnw_bbit;
bool sealed()
Check if list is sealed.
ThreadListSealedException(const char *operation)
Constructor.
ThreadListNotSealedException(const char *format,...)
Constructor.
const char * name()
Name of the thread list.
void clear()
Clear the list.
void start()
Start threads.
void cancel_finalize()
Cancel finalization on all threads.
void push_back_locked(Thread *thread)
Add thread to the end with lock protection.
void seal()
Seal the list.
void set_prepfin_hold(bool hold)
Set prepfin hold on all threads.
void force_stop(ThreadFinalizer *finalizer)
Force stop of all threads.
Thread class encapsulation of pthreads.
void pop_back()
Remove last element.
bool prepare_finalize(ThreadFinalizer *finalizer)
Prepare finalize.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
Thread list sealed exception.
void push_front_locked(Thread *thread)
Add thread to the front with lock protection.
ThreadList & operator=(const ThreadList &tl)
Assignment operator.
ThreadList(const char *tlname="")
Constructor.
Base class for exceptions in Fawkes.
void remove_locked(Thread *thread)
Remove with lock protection.
ThreadList::iterator erase(iterator pos)
Erase element at given position.
void init(ThreadInitializer *initializer, ThreadFinalizer *finalizer)
Initialize threads.
Thread initializer interface.
void wakeup()
Wakeup all threads in list.
void finalize(ThreadFinalizer *finalizer)
Finalize Threads.
void pop_front()
Remove first element.
void push_back(Thread *thread)
Add thread to the end.
Thread list not sealed exception.
void wakeup_unlocked()
Wakeup all threads in list.
void set_name(const char *format,...)
Set name of thread.
void try_recover(std::list< std::string > &recovered_threads)
Check if any of the bad barriers recovered.
void set_maintain_barrier(bool maintain_barrier)
Set if this thread list should maintain a barrier.
Mutex mutual exclusion lock.
void push_front(Thread *thread)
Add thread to the front.
void wakeup_and_wait(unsigned int timeout_sec=0, unsigned int timeout_nanosec=0)
Wakeup threads and wait for them to finish.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
void cancel()
Cancel threads.
Thread finalizer interface.