TrinityCore
|
#include <ThreadSet.h>
Public Types | |
typedef GThread | Thread |
typedef shared_ptr< Thread > | ThreadRef |
typedef shared_ptr< ThreadSet > | Ref |
typedef Array< ThreadRef > ::Iterator | Iterator |
typedef Array< ThreadRef > ::ConstIterator | ConstIterator |
Public Member Functions | |
int | size () const |
int | numStarted () const |
void | start (SpawnBehavior lastThreadBehavior=USE_NEW_THREAD) const |
void | terminate () const |
void | waitForCompletion () const |
void | clear () |
int | removeCompleted () |
int | insert (const ThreadRef &t) |
bool | remove (const ThreadRef &t) |
bool | contains (const ThreadRef &t) const |
Iterator | begin () |
Iterator | end () |
ConstIterator | begin () const |
ConstIterator | end () const |
Public Member Functions inherited from G3D::ReferenceCountedObject | |
virtual | ~ReferenceCountedObject () |
Private Attributes | |
GMutex | m_lock |
Array< ThreadRef > | m_thread |
Manages a set of threads. All methods are threadsafe except for the iterator begin/end.
typedef Array<ThreadRef>::Iterator G3D::ThreadSet::Iterator |
typedef shared_ptr<ThreadSet> G3D::ThreadSet::Ref |
typedef GThread G3D::ThreadSet::Thread |
Intended to allow future use with a template parameter.
typedef shared_ptr<Thread> G3D::ThreadSet::ThreadRef |
ThreadSet::Iterator G3D::ThreadSet::begin | ( | ) |
It is an error to mutate the ThreadSet while iterating through it.
ThreadSet::ConstIterator G3D::ThreadSet::begin | ( | ) | const |
void G3D::ThreadSet::clear | ( | ) |
Remove all (not stopping them)
ThreadSet::Iterator G3D::ThreadSet::end | ( | ) |
ThreadSet::ConstIterator G3D::ThreadSet::end | ( | ) | const |
Inserts a new thread, if it is not already present, and returns the new number of threads.
int G3D::ThreadSet::numStarted | ( | ) | const |
Number of threads that have been started
Removes a thread. Returns true if the thread was present and removed.
int G3D::ThreadSet::removeCompleted | ( | ) |
Removes completed threads and returns the new size.
int G3D::ThreadSet::size | ( | ) | const |
Total number of threads (some of which may be completed).
void G3D::ThreadSet::start | ( | SpawnBehavior | lastThreadBehavior = USE_NEW_THREAD | ) | const |
Start all threads that are not currently started.
lastThreadBehavior | If USE_CURRENT_THREAD, takes the last unstarted thread and executes it manually on the current thread. This helps to take full advantage of the machine when running a large number of jobs and avoids the overhead of a thread start for single-thread groups. Note that this forces start() to block until that thread is complete. |
void G3D::ThreadSet::terminate | ( | ) | const |
Terminate all threads that are currently started
void G3D::ThreadSet::waitForCompletion | ( | ) | const |
Waits until all started threads have completed.
|
private |
Protects m_thread