Turi Create  4.0
turi::thread_group Class Reference

#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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ thread_group()

turi::thread_group::thread_group ( )
inline

Initializes a thread group.

Definition at line 1050 of file pthread_tools.hpp.

Member Function Documentation

◆ join()

void turi::thread_group::join ( )

Waits for all threads to complete execution. const char* exceptions thrown by threads are forwarded to the join() function.

◆ launch() [1/2]

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

◆ launch() [2/2]

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


The documentation for this class was generated from the following file: