Thread lifecycle management group.
More...
#include <thread_group.h>
Thread lifecycle management group.
- Note
- See gtest unit tests Syc.* for a usage examples
dmlc::ThreadGroup::ThreadGroup |
( |
| ) |
|
|
inline |
virtual dmlc::ThreadGroup::~ThreadGroup |
( |
| ) |
|
|
inlinevirtual |
Destructor, perform cleanup. All child threads will be exited when this destructor completes.
bool dmlc::ThreadGroup::add_thread |
( |
std::shared_ptr< Thread > |
thrd | ) |
|
|
inline |
Add a Thread object to this thread group.
- Parameters
-
- Returns
- true if the given thread was added to this ThreadGroup
template<typename StartFunction , typename ThreadType = Thread, typename... Args>
bool dmlc::ThreadGroup::create |
( |
const std::string & |
threadName, |
|
|
bool |
auto_remove, |
|
|
StartFunction |
start_function, |
|
|
Args... |
args |
|
) |
| |
|
inline |
Create and launch a new Thread object which will be owned by this ThreadGroup.
- Template Parameters
-
StartFunction | Function type for the thread 'main' function |
ThreadType | managedThreadclass type (in case it's derived, for instance) |
Args | Arguments to pass to the thread 'main' function |
- Parameters
-
threadName | Name if the thread. Must be unique for a ThreadGroup object |
auto_remove | If true, automatically remove this Thread object from the ThreadGroup owner upon exit |
start_function | The Thread's 'main' function |
args | Arguments to pass to the Thread's 'main' function |
- Returns
- true if the thread was successfully created and added to the ThreadGroup If false is returned, the thread may have already been started, but if something went wrong (ie duplicte thread name for the ThreadGroup), then request_shutdown() will have been been called on the running thread
bool dmlc::ThreadGroup::empty |
( |
| ) |
const |
|
inline |
bool dmlc::ThreadGroup::is_this_thread_in |
( |
| ) |
const |
|
inline |
Check if the current thread a member if this ThreadGroup.
- Returns
- true if the current thread is a member of this thread group
- Note
- This lookup involved a linear search, so for a large number of threads, is it not advised to call this function in a performance-sensitive area
bool dmlc::ThreadGroup::is_thread_in |
( |
std::shared_ptr< Thread > |
thrd | ) |
const |
|
inline |
Check if the current thread is a member of this ThreadGroup.
- Parameters
-
thrd | The thread to search for |
- Returns
- true if the given thread is a member of this ThreadGroup
void dmlc::ThreadGroup::join_all |
( |
| ) |
|
|
inline |
Join all threads in this ThreadGroup.
- Note
- While it is not valid to call 'join' on an auto-remove thread, this function will wait for auto-remove threads to exit (waits for the ThreadGroup to become empty)
bool dmlc::ThreadGroup::remove_thread |
( |
std::shared_ptr< Thread > |
thrd | ) |
|
|
inline |
Remove a Thread object from this thread group.
- Parameters
-
- Returns
- true if the given thread was removed from this ThreadGroup
void dmlc::ThreadGroup::request_shutdown_all |
( |
const bool |
make_all_joinable = true | ) |
|
|
inline |
Call request_shutdown() on all threads in this ThreadGroup.
- Parameters
-
make_all_joinable | If true, remove all auto_remove flags from child threads |
size_t dmlc::ThreadGroup::size |
( |
| ) |
const |
|
inline |
Return the number of threads in this thread group.
- Returns
- Number of threads in this thread group
std::shared_ptr<Thread> dmlc::ThreadGroup::thread_by_name |
( |
const std::string & |
name | ) |
|
|
inline |
Lookup Thread object by name.
- Parameters
-
name | Name of the thread to look up |
- Returns
- A shared pointer to the Thread object
The documentation for this class was generated from the following file: