|
Dawn Framework 1.0
Universal data acquisition framework for embedded systems
|
Portable thread owner abstraction for Dawn components. More...
#include <thread.hxx>
Classes | |
| struct | SThreadConfig |
| Per-thread runtime configuration. More... | |
Public Member Functions | |
| CThreadedObject () | |
| Constructor - initializes thread management state. | |
| virtual | ~CThreadedObject () |
| Destructor - cleans up thread resources. | |
| const SThreadConfig & | getThreadConfig () const |
| Get current thread configuration. | |
| int | getThreadPriority () const |
| Get configured worker thread priority. | |
| int | getThreadScheduler () const |
| Get configured worker thread scheduler policy. | |
| size_t | getThreadStackSize () const |
| Get configured worker thread stack size. | |
| bool | isRunning () const |
| Check if the worker thread is running. | |
| void | setThreadConfig (const SThreadConfig &config) |
| Replace the full thread configuration. | |
| template<typename Func > | |
| void | setThreadFunc (Func &&func) |
| Assign the function executed by threadStart(). | |
| void | setThreadPriority (int priority) |
| Configure worker thread priority. | |
| void | setThreadScheduler (int scheduler) |
| Configure worker thread scheduler policy. | |
| void | setThreadStackSize (size_t stackSize) |
| Configure worker thread stack size. | |
| int | threadStart () |
| Start the worker thread. | |
| int | threadStop () |
| Stop the worker thread. | |
Static Public Attributes | |
| static int | THREAD_PRIORITY_DEFAULT = 0 |
| Default thread priority behavior. | |
| static int | THREAD_SCHEDULER_DEFAULT = -1 |
| Default scheduler behavior. | |
Protected Member Functions | |
| template<typename Func > | |
| int | startWorkerThread (Func &&func) |
| Start the worker thread with a given function. | |
| int | stopWorkerThread () |
| Stop the worker thread. | |
| CThreadedObject & | workerThread () |
| Get a reference to this thread controller. | |
| const CThreadedObject & | workerThread () const |
| Get a const reference to this thread controller. | |
| bool | workerThreadRunning () const |
| Check if the worker thread is running. | |
Portable thread owner abstraction for Dawn components.
Provides the low-level thread lifecycle API used by composed thread owners and the convenience helpers previously exposed by the mixin wrapper.
The worker thread is implemented with POSIX pthreads so Dawn can control stack size, scheduling policy, and priority on a per-thread basis. When no configuration is supplied, the OS default stack size and the creating thread's scheduler settings are used.
Definition at line 31 of file thread.hxx.
| bool CThreadedObject::isRunning | ( | ) | const |
Check if the worker thread is running.
Definition at line 256 of file thread.cxx.
|
inline |
Assign the function executed by threadStart().
| func | Callable object to execute in the worker thread. |
Definition at line 100 of file thread.hxx.
|
inline |
Configure worker thread priority.
| priority | Requested priority (0 = creator default). |
Definition at line 149 of file thread.hxx.
References dawn::CThreadedObject::SThreadConfig::priority.
|
inline |
Configure worker thread scheduler policy.
| scheduler | POSIX scheduler policy (-1 = creator default). |
Definition at line 169 of file thread.hxx.
References dawn::CThreadedObject::SThreadConfig::scheduler.
|
inline |
Configure worker thread stack size.
| stackSize | Requested stack size in bytes (0 = OS default). |
Definition at line 129 of file thread.hxx.
References dawn::CThreadedObject::SThreadConfig::stackSize.
|
inlineprotected |
Start the worker thread with a given function.
| func | Callable object to execute in thread. |
Definition at line 246 of file thread.hxx.
References setThreadFunc(), and threadStart().
|
inlineprotected |
Stop the worker thread.
Definition at line 258 of file thread.hxx.
References threadStop().
| int CThreadedObject::threadStart | ( | ) |
Start the worker thread.
Definition at line 166 of file thread.cxx.
| int CThreadedObject::threadStop | ( | ) |
Stop the worker thread.
Definition at line 240 of file thread.cxx.
|
inlineprotected |
Get a reference to this thread controller.
Definition at line 280 of file thread.hxx.
|
inlineprotected |
Get a const reference to this thread controller.
Definition at line 291 of file thread.hxx.
|
inlineprotected |
Check if the worker thread is running.
Definition at line 269 of file thread.hxx.
References isRunning().
|
static |
Default thread priority behavior.
Value 0 keeps the creator thread's default priority.
Definition at line 40 of file thread.hxx.
|
static |
Default scheduler behavior.
Value -1 keeps the creator thread's current scheduling policy.
Definition at line 48 of file thread.hxx.