cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
osaThread Class Reference

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
 

Detailed Description

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.

See Also
mtsTask

Constructor & Destructor Documentation

osaThread::osaThread ( )

Default constructor. Does nothing.

osaThread::~osaThread ( )

Default destructor. Does nothing.

Member Function Documentation

void osaThread::Create ( void *(*)(void)  threadStart,
const char *  name = 0,
int  priority = 0,
int  policy = SCHED_FIFO 
)
inline

Creates a new thread that will execute the specified function, with no parameters.

template<class _userDataType >
void osaThread::Create ( void *(*)(_userDataType)  threadStart,
_userDataType  userData = _userDataType(),
const char *  name = 0,
int  priority = 0,
int  policy = SCHED_FIFO 
)
inline

Creates a new thread that will execute the specified function, taking a single parameter.

template<class _entryType , class _userDataType >
void osaThread::Create ( _entryType *  obj,
void *(_entryType::*)(_userDataType)  threadStart,
_userDataType  userData = _userDataType(),
const char *  name = 0,
int  priority = 0,
int  policy = SCHED_FIFO 
)
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.

void osaThread::CreateFromCurrentThread ( const char *  name = 0,
int  priority = 0,
int  policy = SCHED_FIFO 
)
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.

void osaThread::CreateFromThreadId ( const osaThreadId threadId,
const char *  name = 0,
int  priority = 0,
int  policy = SCHED_FIFO 
)
inline
void osaThread::CreateInternal ( const char *  name,
void *  func,
void *  userdata 
)
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.

osaThreadId osaThread::GetId ( void  ) const
inline

Return the thread id.

const char* osaThread::GetName ( void  ) const
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.

bool osaThread::IsRunning ( void  ) const
inline

Returns if this thread is running.

bool osaThread::IsValid ( void  ) const
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.

void osaThread::SetThreadName ( const char *  name)
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.

Parameters
timeInSecondsThe amount of time the task is suspended (in seconds)
void osaThread::Wait ( void  )

Wait for the thread to exit.

void osaThread::WaitForWakeup ( void  )
inline

Wait for thread to receive a "wakeup" signal/event.

void osaThread::WaitForWakeup ( double  timeoutInSec)
inline

Wait for thread to receive a "wakeup" signal/event.

void osaThread::Wakeup ( void  )
inline

Signal the thread to wake up.

Friends And Related Function Documentation

friend class osaThreadTest
friend

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