#include <R3D/Threads/R3DThreadGroup.h>
The class is based off of the Boost::thread_group class. This class adds a maximum number of threads that can be in use at any one time and is a user settable value and NOT based off of hardware capabilities. Thus a user is capable of starting 100 threads on a single processor machine. You have been warned. You should instantiate this class like normal then use the "createThread" method to create your threads. When the maximum number of threads is reached called createThread will result in a blocking operation until another thread is complete and removed from the group. See the docs for the R3DAbstractThread which is a companion class to this class.
Public Member Functions | |
int | getMaxThreads () |
Returns the maximum number of threads this group is managing. | |
void | setShouldDeleteThreadsOnDestruction (bool c) |
When this class is destroyed, the pointers to the actual thread objects will be 'delete'ed if this is set to TRUE. | |
int | waitForOpenSlot () |
Waits for an open slot to start another thread. | |
template<typename T> | |
boost::thread * | startThread (T t) |
Creates a new thread using the class T as the function to run on the thread. | |
void | add_thread (thread *thrd, int slot) |
Adds a thread to this group. | |
void | remove_thread (boost::thread *thread) |
Removes a thread from the thread group. | |
void | join_all () |
calls "join()" on all the threads currently running and managed by this class. | |
void | interrupt_all () |
Calls interrupt() on all the threads being managed by this class. | |
size_t | size () |
Returns the total number of threads this class can manage. | |
void | markThreadComplete (int slot) |
Sets a flag to mark a specific thread as having completed its execution. | |
Static Public Member Functions | |
static R3DThreadGroup::Pointer | New (int maxThreads) |
Static new method which should be used to instantiate this class. | |
Protected Member Functions | |
R3DThreadGroup (int maxThreads) | |
Protected constructor as the Static New method should be use instead. |
R3DThreadGroup::R3DThreadGroup | ( | int | maxThreads | ) | [protected] |
Protected constructor as the Static New method should be use instead.
maxThreads | The maximum number of threads to run concurrently |
R3DThreadGroup::Pointer R3DThreadGroup::New | ( | int | maxThreads | ) | [static] |
Static new method which should be used to instantiate this class.
maxThreads | The maximum concurrent threads to allow at any given time |
int R3DThreadGroup::getMaxThreads | ( | ) |
Returns the maximum number of threads this group is managing.
void R3DThreadGroup::setShouldDeleteThreadsOnDestruction | ( | bool | c | ) |
When this class is destroyed, the pointers to the actual thread objects will be 'delete'ed if this is set to TRUE.
The default for this class is a setting of true. If you set this value to true YOU WILL NEED TO properly cleanup the memory and resources used by the thread.
c |
int R3DThreadGroup::waitForOpenSlot | ( | ) |
Waits for an open slot to start another thread.
boost::thread* R3DThreadGroup::startThread | ( | T | t | ) | [inline] |
Creates a new thread using the class T as the function to run on the thread.
t | The function to run on the thread. |
void R3DThreadGroup::add_thread | ( | thread * | thrd, | |
int | slot | |||
) |
Adds a thread to this group.
thrd | The thread to add | |
slot | The slot number to use |
void R3DThreadGroup::remove_thread | ( | boost::thread * | thread | ) |
Removes a thread from the thread group.
thread | The thread to remove from the thread group. |
size_t R3DThreadGroup::size | ( | ) |
Returns the total number of threads this class can manage.
void R3DThreadGroup::markThreadComplete | ( | int | slot | ) |
Sets a flag to mark a specific thread as having completed its execution.
slot |