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

Public Member Functions

 thread ()
 
virtual ~thread ()
 
bool setStackSize (size_t stacksize)
 
bool getStackSize (size_t *stacksize)
 
bool spawn (void *(*function)(void *), void *arg, bool detached)
 
void exit (int32_t *status)
 
bool wait (int32_t *status)
 
bool detach ()
 
bool raiseSignal (int32_t signum)
 
void retryFailedSpawn ()
 
void dontRetryFailedSpawn ()
 
bool getRetryFailedSpawn ()
 

Static Public Member Functions

static bool supported ()
 

Detailed Description

The thread class provides a simple thread implementation.

Constructor & Destructor Documentation

◆ thread()

thread::thread ( )

Creates an instance of the thread class.

◆ ~thread()

virtual thread::~thread ( )
virtual

Deletes this instance of the thread class.

Member Function Documentation

◆ detach()

bool thread::detach ( )

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

◆ dontRetryFailedSpawn()

void thread::dontRetryFailedSpawn ( )

Causes spawn() calls not to be automatically retried if they fail because of insufficient system resources. If set, if a spawn() fails, the system error is set to EAGAIN and the spawn() must be retried by the calling program.

◆ exit()

void thread::exit ( int32_t *  status)

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

◆ getRetryFailedSpawn()

bool thread::getRetryFailedSpawn ( )

Returns true if failed spawn() calls will be retried and false otherwise.

◆ getStackSize()

bool thread::getStackSize ( size_t *  stacksize)

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

◆ raiseSignal()

bool thread::raiseSignal ( int32_t  signum)

Sends signal "signum" to the thread.

◆ retryFailedSpawn()

void thread::retryFailedSpawn ( )

Causes spawn() calls to be automatically retried if they fail because of insufficient system resources. This is the default behavior. Otherwise, if a spawn() fails, the system error is set to EAGAIN and the spawn() must be retried by the calling program.

◆ setStackSize()

bool thread::setStackSize ( size_t  stacksize)

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

◆ spawn()

bool thread::spawn ( void *(*)(void *)  function,
void *  arg,
bool  detached 
)

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

◆ supported()

static bool thread::supported ( )
static

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

◆ wait()

bool thread::wait ( int32_t *  status)

Waits for the spawn()ed function 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.