TinyThread++ 1.1
|
Thread class. More...
#include <tinythread.h>
Classes | |
class | id |
Thread ID. More... | |
Public Member Functions | |
thread () | |
Default constructor. | |
thread (void(*aFunction)(void *), void *aArg) | |
Thread starting constructor. | |
~thread () | |
Destructor. | |
void | join () |
Wait for the thread to finish (join execution flows). | |
bool | joinable () const |
Check if the thread is joinable. | |
void | detach () |
Detach from the thread. | |
id | get_id () const |
Return the thread ID of a thread object. | |
native_handle_type | native_handle () |
Get the native handle for this thread. | |
Static Public Member Functions | |
static unsigned | hardware_concurrency () |
Determine the number of threads which can possibly execute concurrently. |
Thread class.
thread | ( | ) | [inline] |
Default constructor.
Construct a thread
object without an associated thread of execution (i.e. non-joinable).
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. |
~thread | ( | ) |
Destructor.
std::terminate()
will be called, which terminates the process. It is always wise to do join()
before deleting a thread object. void 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.
static unsigned hardware_concurrency | ( | ) | [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 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 joinable | ( | ) | const |
Check if the thread is joinable.
A thread object is joinable if it has an associated thread of execution.
native_handle_type native_handle | ( | ) | [inline] |
Get the native handle for this thread.
HANDLE
, and under POSIX systems, this is a pthread_t
.