Go to the documentation of this file.
23 bool& _should_terminate;
26 Runner(std::mutex& mutex,
bool& _should_terminate);
33 template <
typename State>
38 using ThreadFn = std::function<void(
Runner, State&,
size_t)>;
41 std::vector<std::thread> _threads;
43 std::vector<State> _states;
49 bool _should_terminate;
68 void launch(ThreadFn fn, int64_t max_worker_threads = 0);
81 void thread_main(int64_t index);
Manages the execution of a group of threads.
Definition: group.hpp:34
bool alive()
True if threads should continue executing.
Definition: group.cpp:8
ThreadGroup & operator=(ThreadGroup &)=delete
int64_t get_worker_count() const
Get total number of workers.
Definition: group.inl:52
std::vector< State > & get_states()
Obtain threads state.
Definition: group.inl:47
void terminate()
Terminate thread execution, this operation is irrecuperable.
Definition: group.inl:38
ThreadGroup()
Create disabled thread group.
Definition: group.inl:8
Runner(std::mutex &mutex, bool &_should_terminate)
Definition: group.cpp:5
Used to control threads execution.
Definition: group.hpp:19
void launch(ThreadFn fn, int64_t max_worker_threads=0)
Create threads and begin execution.
Definition: group.inl:16
virtual ~ThreadGroup()
Stops and joins all threads.
Definition: group.inl:11