Rudiments
Public Member Functions | Static Public Member Functions | List of all members
thread Class Reference

Public Member Functions

 thread ()
 
virtual ~thread ()
 
void setFunction (void *(*function)(void *), void *arg)
 
bool setStackSize (size_t stacksize)
 
bool getStackSize (size_t *stacksize)
 
bool create ()
 
void exit (int32_t *status)
 
bool join (int32_t *status)
 
bool detach ()
 

Static Public Member Functions

static bool supportsThreads ()
 

Detailed Description

The thread class provides a simple thread implementation.

Constructor & Destructor Documentation

thread::thread ( )

Creates an instance of the thread class.

virtual thread::~thread ( )
virtual

Deletes this instance of the thread class.

Member Function Documentation

bool thread::create ( )

Starts a new thread by running whatever function was set by the setFunction() method. Returns true on success and false if an error occurred.

bool thread::detach ( )

Detaches the thread so that it may exit without calling exit() and without another thread needing to call join(). Returns true on success and false if an error occurred.

void thread::exit ( int32_t *  status)

Causes a thread to exit with the value stored in the location pointed to by "status". If another thread is waiting on this thread using join(), then that thread's join() method will fall through.

bool thread::getStackSize ( size_t *  stacksize)

Sets "stacksize" to this thread's stack size. Returns true on success and false if an error occurred.

bool thread::join ( int32_t *  status)

Waits for the function set by setFunction() and run by create() to call exit() or return. This method should be called by a second thread. If non-NULL, "status" will be set to the exit status of the thread. Returns true on success and false if an error occurred.

void thread::setFunction ( void *(*)(void *)  function,
void *  arg 
)

Defines the function that will be run when create() is called.

bool thread::setStackSize ( size_t  stacksize)

Sets this thread's stack size to "stacksize". Returns true on success and false if an error occurred.

static bool thread::supportsThreads ( )
static

Returns true if the platform supports threads and rudiments was built with thread support and false otherwise.