A small wrapper around the system thread. More...
#include <thread.h>
Public Types | |
typedef pthread_t | native_handle_type |
The native handle type, made available with requiring specific knowledge of whether it is a posix or win32 handle. | |
Public Member Functions | |
Thread () | |
Default constructor. More... | |
Thread (void(*aFunction)(void *)) | |
Thread starting constructor with no parameters. More... | |
Thread (void(*aFunction)(void *), void *aArg) | |
Thread starting constructor. More... | |
~Thread () | |
Destructor. More... | |
void | detach () |
Detach from the thread. More... | |
ThreadId | get_id () const |
Return the thread ID of a thread object. More... | |
void | join () |
Wait for the thread to finish (join execution flows). More... | |
bool | joinable () const |
Check if the thread is joinable. More... | |
native_handle_type | native_handle () |
Get the native handle for this thread. More... | |
Static Public Member Functions | |
static unsigned | hardware_concurrency () |
Determine the number of threads which can possibly execute concurrently. More... | |
A small wrapper around the system thread.
In general game code should not be creating this if they are using the DAG Frame Scheduler, as it tries to maintain control over the threads created by a game. This tries to keep the names the same as the standard thread, and might at some point be replace by some template machinery that wraps the minor difference that currently exist.
|
inline |
|
explicit |
Thread starting constructor with no parameters.
[in] | aFunction | A function pointer to a function of type: void fun(void * arg)
|
Mezzanine::Threading::Thread::Thread | ( | void(*)(void *) | aFunction, |
void * | aArg | ||
) |
Thread starting constructor.
Construct a thread
object with a new thread of execution.
[in] | aFunction | A function pointer to a function of type: void fun(void * arg)
|
[in] | aArg | Argument to the thread function. |
Mezzanine::Threading::Thread::~Thread | ( | ) |
Destructor.
std::terminate()
will be called, which terminates the process. It is always wise to do join()
before deleting a thread object. void Mezzanine::Threading::Thread::detach | ( | ) |
Detach from the thread.
After calling detach()
, the thread object is no longer assicated with a thread of execution (i.e. it is not joinable). The thread continues execution without the calling thread blocking, and when the thread ends execution, any owned resources are released.
ThreadId Mezzanine::Threading::Thread::get_id | ( | ) | const |
Return the thread ID of a thread object.
|
static |
Determine the number of threads which can possibly execute concurrently.
This function is useful for determining the optimal number of threads to use for a task.
void Mezzanine::Threading::Thread::join | ( | ) |
Wait for the thread to finish (join execution flows).
After calling join()
, the thread object is no longer associated with a thread of execution (i.e. it is not joinable, and you may not join with it nor detach from it).
bool Mezzanine::Threading::Thread::joinable | ( | ) | const |
Check if the thread is joinable.
A thread object is joinable if it has an associated thread of execution.
|
inline |