A child thread object that may be joined by parent.
More...
#include <thread.h>
|
void | background (void) |
| Start execution of child context as background thread.
|
|
void | start (int priority=0) |
| Start execution of child context.
|
|
virtual void | exit (void) |
| Exit the thread context.
|
|
bool | isRunning (void) const |
|
| operator bool () const |
|
bool | operator! () const |
|
void | setPriority (void) |
| Set thread priority without disrupting scheduling if possible.
|
|
virtual | ~Thread () |
| Destroy thread object, thread-specific data, and execution context.
|
|
|
bool | is_active (void) const |
| Check if running.
|
|
void | join (void) |
| Join thread with parent.
|
|
| JoinableThread (size_t size=0) |
| Create a joinable thread with a known context stack size.
|
|
virtual void | run (void)=0 |
| Abstract interface for thread context run method.
|
|
virtual | ~JoinableThread () |
| Delete child thread.
|
|
void | map (void) |
| Map thread for get method.
|
|
| Thread (size_t stack=0) |
| Create a thread object that will have a preset stack size.
|
|
|
static size_t | cache (void) |
| Get cache line size.
|
|
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 void | release (void) |
|
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.
|
|
enum | { R_UNUSED
} |
|
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
- Examples
- thread.cpp.
Definition at line 823 of file thread.h.
◆ JoinableThread()
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. |
◆ ~JoinableThread()
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.
◆ background()
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 875 of file thread.h.
◆ is_active()
bool ucommon::JoinableThread::is_active |
( |
void | | ) |
const |
|
protectedvirtual |
◆ join()
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.
◆ run()
virtual void ucommon::JoinableThread::run |
( |
void | | ) |
|
|
protectedpure virtual |
Abstract interface for thread context run method.
Implements ucommon::Thread.
◆ start()
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
-
◆ joining
volatile bool ucommon::JoinableThread::joining |
|
protected |
◆ running
volatile bool ucommon::JoinableThread::running |
|
protected |
The documentation for this class was generated from the following file:
- /builddir/build/BUILD/ucommon-7.0.0-build/ucommon-7.0.0/inc/ucommon/thread.h