ucommon
|
A child thread object that may be joined by parent. More...
#include <thread.h>
Public Member Functions | |
void | background (void) |
Start execution of child context as background thread. | |
bool | isRunning (void) |
Check if running. | |
void | start (int priority=0) |
Start execution of child context. | |
Protected Member Functions | |
void | join (void) |
Join thread with parent. | |
JoinableThread (size_t size=0) | |
Create a joinable thread with a known context stack size. | |
virtual | ~JoinableThread () |
Delete child thread. | |
Protected Attributes | |
volatile bool | joining |
volatile bool | running |
A child thread object that may be joined by parent.
A child thread is a type of thread in which the parent thread (or process main thread) can then wait for the child thread to complete and then delete the child object. The parent thread can wait for the child thread to complete either by calling join, or performing a "delete" of the derived child object. In either case the parent thread will suspend execution until the child thread exits.
ucommon::JoinableThread::JoinableThread | ( | size_t | size = 0 | ) | [protected] |
Create a joinable thread with a known context stack size.
size | of stack for thread context or 0 for default. |
virtual ucommon::JoinableThread::~JoinableThread | ( | ) | [protected, virtual] |
Delete child thread.
Parent thread suspends until child thread run method completes or child thread calls it's exit method.
void ucommon::JoinableThread::background | ( | void | ) | [inline] |
void ucommon::JoinableThread::join | ( | void | ) | [protected] |
Join thread with parent.
Calling from a child thread to exit is now depreciated behavior and in the future will not be supported. Threads should always return through their run() method.
void ucommon::JoinableThread::start | ( | int | priority = 0 | ) |
Start execution of child context.
This must be called after the child object is created (perhaps with "new") and before it can be joined. This method actually begins the new thread context, which then calls the object's run method. Optionally raise the priority of the thread when it starts under realtime priority.
priority | of child thread. |