#include <bslmt_threadgroup.h>
This class provides a simple mechanism for managing a group of joinable threads. The destructor ensures that any running threads are detached so that resources are not leaked. This class is thread-enabled, thread-safe, and exception-neutral.
See bslmt_threadgroup
◆ ThreadGroup()
Create an empty thread group. Optionally specify basicAllocator will be used to supply memory. If basicAllocator is 0, the currently installed default allocator will be used.
◆ ~ThreadGroup()
| bslmt::ThreadGroup::~ThreadGroup |
( |
| ) |
|
Destroy this object. Any threads not joined will be allowed to run independently, and will no longer be joinable.
◆ addThread() [1/2]
template<class INVOKABLE >
| int bslmt::ThreadGroup::addThread |
( |
const INVOKABLE & |
functor | ) |
|
|
inline |
Begin executing the specified invokable functor in a new thread, using the optionally specified thread attributes. Return 0 on success, and a non-zero value otherwise. INVOKABLE shall be a copy-constructible type having the equivalent of void operator()(). Note that threads are always created joinable, regardless of the mode specified in attributes.
◆ addThread() [2/2]
template<class INVOKABLE >
| int bslmt::ThreadGroup::addThread |
( |
const INVOKABLE & |
functor, |
|
|
const ThreadAttributes & |
attributes |
|
) |
| |
◆ addThreads() [1/2]
template<class INVOKABLE >
| int bslmt::ThreadGroup::addThreads |
( |
const INVOKABLE & |
functor, |
|
|
int |
numThreads |
|
) |
| |
|
inline |
Begin executing the specified invokable functor in the specified new numThreads, using the optionally specified thread attributes. Return numThreads on success, or the number of threads successfully started otherwise. INVOKABLE shall be a copy-constructible type having the equivalent of void operator()(). Note that threads are always created joinable, regardless of the mode specified in attributes.
◆ addThreads() [2/2]
template<class INVOKABLE >
| int bslmt::ThreadGroup::addThreads |
( |
const INVOKABLE & |
functor, |
|
|
int |
numThreads, |
|
|
const ThreadAttributes & |
attributes |
|
) |
| |
◆ joinAll()
| void bslmt::ThreadGroup::joinAll |
( |
| ) |
|
Block the calling thread until all threads started in this group have finished executing.
◆ numThreads()
| int bslmt::ThreadGroup::numThreads |
( |
| ) |
const |
|
inline |
Return a snapshot of the number of threads started in this group that have not been joined.
The documentation for this class was generated from the following file: