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.
|
virtual void | exit (void) |
| Exit the thread context.
|
| operator bool () |
virtual void | run (void)=0 |
| Abstract interface for thread context run method.
|
void | setPriority (void) |
| Set thread priority without disrupting scheduling if possible.
|
virtual | ~Thread () |
| Destroy thread object, thread-specific data, and execution context.
|
void | map (void) |
| Map thread for get method.
|
| Thread (size_t stack=0) |
| Create a thread object that will have a preset stack size.
|
Protected Attributes |
volatile bool | joining |
volatile bool | running |
Additional Inherited Members |
static void | concurrency (int level) |
| Set concurrency level of process.
|
static bool | equal (pthread_t thread1, pthread_t thread2) |
| Determine if two thread identifiers refer to the same thread.
|
static Thread * | get (void) |
| Get mapped thread object.
|
static void | init (void) |
| Used to initialize threading library.
|
static void | policy (int polid) |
| Used to specify scheduling policy for threads above priority "0".
|
static pthread_t | self (void) |
| Get current thread id.
|
static void | sleep (timeout_t timeout) |
| Sleep current thread for a specified time period.
|
static void | yield (void) |
| Yield execution context of the current thread.
|
Detailed Description
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.
- Author:
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 1613 of file thread.h.
Constructor & Destructor Documentation
ucommon::JoinableThread::JoinableThread |
( |
size_t |
size = 0 | ) |
|
|
protected |
Create a joinable thread with a known context stack size.
- Parameters:
-
size | of stack for thread context or 0 for default. |
virtual ucommon::JoinableThread::~JoinableThread |
( |
| ) |
|
|
protectedvirtual |
Delete child thread.
Parent thread suspends until child thread run method completes or child thread calls it's exit method.
Member Function Documentation
void ucommon::JoinableThread::background |
( |
void |
| ) |
|
|
inline |
Start execution of child context as background thread.
This is assumed to be off main thread, with a priority lowered by one.
Definition at line 1659 of file thread.h.
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.
- Parameters:
-
The documentation for this class was generated from the following file: