Fawkes API
Fawkes Development Version
|
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_finalizer.h>
30 #include <core/threading/thread_initializer.h>
31 #include <core/utils/lock_list.h>
41 class InterruptibleBarrier;
43 class ThreadListSealedException :
public Exception
59 ThreadList(
bool maintain_barrier,
const char *tlname =
"");
64 void set_name(
const char *format, ...);
79 void wakeup_and_wait(
unsigned int timeout_sec = 0,
unsigned int timeout_nanosec = 0);
85 void try_recover(std::list<std::string> &recovered_threads);
97 ThreadList::iterator
erase(iterator pos);
116 void notify_of_failed_init();
117 void update_barrier();
122 Mutex * finalize_mutex_;
125 std::list<std::pair<InterruptibleBarrier *, ThreadList>> wnw_bad_barriers_;
126 std::list<std::pair<InterruptibleBarrier *, ThreadList>>::iterator wnw_bbit_;
bool sealed()
Check if list is sealed.
void force_stop(ThreadFinalizer *finalizer)
Force stop of all threads.
void wakeup()
Wakeup all threads in list.
void clear()
Clear the list.
void set_name(const char *format,...)
Set name of thread.
void remove(Thread *thread)
Remove with lock protection.
void set_maintain_barrier(bool maintain_barrier)
Set if this thread list should maintain a barrier.
ThreadList::iterator erase(iterator pos)
Erase element at given position.
void push_back(Thread *thread)
Add thread to the end.
ThreadListSealedException(const char *operation)
Constructor.
ThreadListNotSealedException(const char *format,...)
Constructor.
void set_prepfin_hold(bool hold)
Set prepfin hold on all threads.
void cancel()
Cancel threads.
void push_front_locked(Thread *thread)
Add thread to the front with lock protection.
const char * name()
Name of the thread list.
ThreadList & operator=(const ThreadList &tl)
Assignment operator.
void finalize(ThreadFinalizer *finalizer)
Finalize Threads.
void pop_front()
Remove first element.
bool prepare_finalize(ThreadFinalizer *finalizer)
Prepare finalize.
void remove_locked(Thread *thread)
Remove with lock protection.
void pop_back()
Remove last element.
void init(ThreadInitializer *initializer, ThreadFinalizer *finalizer)
Initialize threads.
void try_recover(std::list< std::string > &recovered_threads)
Check if any of the bad barriers recovered.
void start()
Start threads.
void push_front(Thread *thread)
Add thread to the front.
ThreadList(const char *tlname="")
Constructor.
void push_back_locked(Thread *thread)
Add thread to the end with lock protection.
void wakeup_unlocked()
Wakeup all threads in list.
void cancel_finalize()
Cancel finalization on all threads.
void seal()
Seal the list.
void wakeup_and_wait(unsigned int timeout_sec=0, unsigned int timeout_nanosec=0)
Wakeup threads and wait for them to finish.