TinyThread++: thread Class Reference

# thread Class Reference

Thread class. More...

`#include <tinythread.h>`

List of all members.

## 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.
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.

## Detailed Description

Thread class.

## Constructor & Destructor Documentation

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.

Parameters:

  `[in]` | aFunction | A function pointer to a function of type: `void fun(void * arg)`
  `[in]` | aArg | Argument to the thread function.

Note:
  This constructor is not fully compatible with the standard C++ thread class. It is more similar to the pthread_create() (POSIX) and CreateThread() (Windows) functions.

~thread | ( |  | ) |

Destructor.

Note:
  If the thread is joinable upon destruction, `std::terminate()` will be called, which terminates the process. It is always wise to do `join()` before deleting a thread object.

## Member Function Documentation

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.

Returns:
  The number of hardware thread contexts in the system.

Note:
  If this value is not defined, the function returns zero (0).

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.

Note:
  Under Windows, this is a `HANDLE`, and under POSIX systems, this is a `pthread_t`.

The documentation for this class was generated from the following file:

- tinythread.h