Turi Create
4.0
|
#include <core/parallel/pthread_tools.hpp>
Public Member Functions | |
thread_group () | |
void | launch (const boost::function< void(void)> &spawn_function) |
void | launch (const boost::function< void(void)> &spawn_function, size_t cpu_id) |
void | join () |
size_t | running_threads () |
Returns the number of running threads. | |
~thread_group () | |
Destructor. Waits for all threads to complete execution. | |
Manages a collection of threads.
The thread_group object performs limited exception forwarding. exception throws within a thread of type const char* will be caught and forwarded to the join() function. If the call to join() is wrapped by a try-catch block, the exception will be caught safely and thread cleanup will be completed properly.
If multiple threads are running in the thread-group, the master should test if running_threads() is > 0, and retry the join().
Definition at line 1035 of file pthread_tools.hpp.
|
inline |
Initializes a thread group.
Definition at line 1050 of file pthread_tools.hpp.
void turi::thread_group::join | ( | ) |
Waits for all threads to complete execution. const char* exceptions thrown by threads are forwarded to the join() function.
void turi::thread_group::launch | ( | const boost::function< void(void)> & | spawn_function | ) |
Launch a single thread which calls spawn_function No CPU affinity is set so which core it runs on is up to the OS Scheduler
void turi::thread_group::launch | ( | const boost::function< void(void)> & | spawn_function, |
size_t | cpu_id | ||
) |
Launch a single thread which calls spawn_function Also sets CPU Affinity