Rudiments

- Main Page
- Classes

- Class List
- Class Hierarchy
- Class Members

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 | setArgument (void *arg)
bool | setStackSize (size_t stacksize)
bool | getStackSize (size_t *stacksize)
bool | run ()
bool | run (void *arg)
bool | runDetached ()
bool | runDetached (void *arg)
void | exit (int32_t *status)
bool | join (int32_t *status)
bool | detach ()
bool | raiseSignal (int32_t signum)
void | retryFailedRun ()
void | dontRetryFailedRun ()
bool | getRetryFailedRun ()

## 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::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::dontRetryFailedRun | ( |  | ) |

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

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 join(), then that thread's join() method will fall through.

bool thread::getRetryFailedRun | ( |  | ) |

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

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 run() 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.

bool thread::raiseSignal | ( | int32_t | signum | ) |

Sends signal "signum" to the thread.

void thread::retryFailedRun | ( |  | ) |

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

bool thread::run | ( |  | ) |

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.

bool thread::run | ( | void * | arg | ) |

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

bool thread::runDetached | ( |  | ) |

Starts a new already-detached 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.

bool thread::runDetached | ( | void * | arg | ) |

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

void thread::setArgument | ( | void * | arg | ) |

Defines the argument that will be passed to the function when run() is called.

void thread::setFunction | ( | void *(*)(void *) | function | ) |

Defines the function that will be run when run() 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.