cisst-saw
|
Define a thread object. More...
#include <osaThread.h>
Public Member Functions | |
osaThread () | |
~osaThread () | |
void | Create (void *(*threadStart)(void), const char *name=0, int priority=0, int policy=SCHED_FIFO) |
template<class _userDataType > | |
void | Create (void *(*threadStart)(_userDataType), _userDataType userData=_userDataType(), const char *name=0, int priority=0, int policy=SCHED_FIFO) |
template<class _entryType , class _userDataType > | |
void | Create (_entryType *obj, void *(_entryType::*threadStart)(_userDataType), _userDataType userData=_userDataType(), const char *name=0, int priority=0, int policy=SCHED_FIFO) |
void | CreateFromCurrentThread (const char *name=0, int priority=0, int policy=SCHED_FIFO) |
void | CreateFromThreadId (const osaThreadId &threadId, const char *name=0, int priority=0, int policy=SCHED_FIFO) |
void | Delete (void) |
void | Wait (void) |
void | WaitForWakeup (void) |
void | WaitForWakeup (double timeoutInSec) |
void | Wakeup (void) |
const char * | GetName (void) const |
osaThreadId | GetId (void) const |
PriorityType | GetPriority (void) const |
void | SetPriority (PriorityType priority) |
SchedulingPolicyType | GetSchedulingPolicy (void) |
void | SetSchedulingPolicy (SchedulingPolicyType policy) |
void | Sleep (double timeInSeconds) |
bool | IsRunning (void) const |
bool | IsValid (void) const |
Protected Member Functions | |
void | CreateInternal (const char *name, void *func, void *userdata) |
void | SetThreadName (const char *name) |
Friends | |
class | osaThreadTest |
Define a thread object.
The thread class is just a wrapper on the OS-specific thread management functions. For now, wraps functions such as CreateThread, DeleteThread, GetThreadPriority, SetThreadPriority and so on. Additional functionality, such as inter-thread communication, maintenance of state information, etc., are provided by the mtsTask class.
osaThread::osaThread | ( | ) |
Default constructor. Does nothing.
osaThread::~osaThread | ( | ) |
Default destructor. Does nothing.
|
inline |
Creates a new thread that will execute the specified function, with no parameters.
|
inline |
Creates a new thread that will execute the specified function, taking a single parameter.
|
inline |
Creates a new thread that will execute the specified class member function. Note that the object is copied to the heap so it remains valid, even if the original object is destroyed.
|
inline |
Initialize the thread object so that it refers to the calling thread, rather than creating a new thread. This allows existing threads to intermix with newly created threads.
|
inline |
|
protected |
Creates a new thread.
void osaThread::Delete | ( | void | ) |
Deletes a thread. Deletes (removes from memory) everything associated with a thread, e.g. stack, local data, static variables.
|
inline |
Return the thread id.
|
inline |
Return the thread name.
PriorityType osaThread::GetPriority | ( | void | ) | const |
Get the OS independent priority of the thread.
SchedulingPolicyType osaThread::GetSchedulingPolicy | ( | void | ) |
Get the OS independent scheduling policy of the thread. Will not be available on all platforms or will return a constant.
|
inline |
Returns if this thread is running.
|
inline |
Returns whether the thread exists (is valid).
void osaThread::SetPriority | ( | PriorityType | priority | ) |
Set the OS independent priority of the thread.
void osaThread::SetSchedulingPolicy | ( | SchedulingPolicyType | policy | ) |
Set the OS independent scheduling policy of the thread. Will not be available on all platforms.
|
protected |
void osaThread::Sleep | ( | double | timeInSeconds | ) |
Delay/suspend execution of the calling thread for the specified time. On some platforms, this method provides a better implementation of osaSleep, provided that it is called from the thread associated with this instance of the class. In this case, the Sleep will also be terminated by any call to Wakeup. If called from a different thread, it just calls osaSleep and is therefore not affected by any calls to Wakeup.
timeInSeconds | The amount of time the task is suspended (in seconds) |
void osaThread::Wait | ( | void | ) |
Wait for the thread to exit.
|
inline |
Wait for thread to receive a "wakeup" signal/event.
|
inline |
Wait for thread to receive a "wakeup" signal/event.
|
inline |
Signal the thread to wake up.
|
friend |