TinyThread++ 1.1
Classes | Public Member Functions | Static Public Member Functions
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.
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.

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]aFunctionA function pointer to a function of type: void fun(void * arg)
[in]aArgArgument 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

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.

Returns:
The number of hardware thread contexts in the system.
Note:
If this value is not defined, the function returns zero (0).
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.

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: