|
DelegateMQ
|
Cross-platform thread for any system supporting C++11 std::thread (e.g. Windows, Linux). More...
#include <Thread.h>
Signals | |
| void | SignalDispatch (std::shared_ptr< dmq::DelegateMsg > msg) |
Public Member Functions | |
| Thread (const std::string &threadName, size_t maxQueueSize=0) | |
| ~Thread () | |
| bool | CreateThread () |
| void | ExitThread () |
| osThreadId_t | GetThreadId () |
| void | SetThreadPriority (osPriority_t priority) |
| osPriority_t | GetThreadPriority () |
| Get current priority. | |
| std::string | GetThreadName () |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) override |
| Enqueues a delegate message for execution on this thread. | |
| Thread (const std::string &threadName, size_t maxQueueSize=0) | |
| ~Thread () | |
| Destructor. | |
| bool | CreateThread () |
| void | ExitThread () |
| Terminate the thread gracefully. | |
| TaskHandle_t | GetThreadId () |
| Get the ID of this thread instance. | |
| std::string | GetThreadName () |
| Get thread name. | |
| void | SetThreadPriority (int priority) |
| void | SetStackMem (StackType_t *stackBuffer, uint32_t stackSizeInWords) |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) override |
| Enqueues a delegate message for execution on this thread. | |
| Thread (const std::string &threadName) | |
| ~Thread () | |
| Destructor. | |
| bool | CreateThread () |
| Create and start the internal QThread. | |
| void | ExitThread () |
| Stop the QThread. | |
| QThread * | GetThreadId () |
| Get the QThread pointer (used as the ID) | |
| std::string | GetThreadName () const |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) override |
| Enqueues a delegate message for execution on this thread. | |
| Thread (const std::string &threadName, size_t maxQueueSize=0) | |
| ~Thread () | |
| Destructor. | |
| bool | CreateThread (std::optional< dmq::Duration > watchdogTimeout=std::nullopt) |
| void | ExitThread () |
| Called once at program exit to shut down the worker thread. | |
| std::thread::id | GetThreadId () |
| Get the ID of this thread instance. | |
| std::string | GetThreadName () |
| Get thread name. | |
| size_t | GetQueueSize () |
| Get size of thread message queue. | |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) |
| Thread (const std::string &threadName, size_t maxQueueSize=0) | |
| ~Thread () | |
| Destructor. | |
| bool | CreateThread () |
| void | ExitThread () |
| Terminate the thread gracefully. | |
| TX_THREAD * | GetThreadId () |
| Get the ID of this thread instance. | |
| void | SetThreadPriority (UINT priority) |
| UINT | GetThreadPriority () |
| Get current priority. | |
| std::string | GetThreadName () |
| Get thread name. | |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) override |
| Enqueues a delegate message for execution on this thread. | |
| Thread (const std::string &threadName, size_t maxQueueSize=0) | |
| virtual | ~Thread () |
| Destructor. | |
| bool | CreateThread (std::optional< dmq::Duration > watchdogTimeout=std::nullopt) |
| void | ExitThread () |
| Called once at program exit to shut down the worker thread. | |
| DWORD | GetThreadId () |
| Get the ID of this thread instance. | |
| std::string | GetThreadName () |
| Get thread name. | |
| size_t | GetQueueSize () |
| Get size of thread message queue. | |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) override |
| Thread (const std::string &threadName) | |
| ~Thread () | |
| bool | CreateThread () |
| void | ExitThread () |
| k_tid_t | GetThreadId () |
| std::string | GetThreadName () |
| virtual void | DispatchDelegate (std::shared_ptr< dmq::DelegateMsg > msg) override |
| Enqueues a delegate message for execution on this thread. | |
Public Member Functions inherited from dmq::IThread | |
| virtual | ~IThread ()=default |
| Destructor. | |
Static Public Member Functions | |
| static osThreadId_t | GetCurrentThreadId () |
| static TaskHandle_t | GetCurrentThreadId () |
| Get the ID of the currently executing thread. | |
| static QThread * | GetCurrentThreadId () |
| Get the current executing QThread pointer. | |
| static std::thread::id | GetCurrentThreadId () |
| Get the ID of the currently executing thread. | |
| static TX_THREAD * | GetCurrentThreadId () |
| Get the ID of the currently executing thread. | |
| static DWORD | GetCurrentThreadId () |
| Get the ID of the currently executing thread. | |
| static k_tid_t | GetCurrentThreadId () |
Static Public Attributes | |
| static const uint32_t | DEFAULT_QUEUE_SIZE = 20 |
| Default queue size if 0 is passed. | |
| static const size_t | DEFAULT_QUEUE_SIZE = 20 |
| Default queue size if 0 is passed. | |
| static const ULONG | DEFAULT_QUEUE_SIZE = 20 |
| Default queue size if 0 is passed. | |
Cross-platform thread for any system supporting C++11 std::thread (e.g. Windows, Linux).
Windows-native thread for systems using the Win32 API.
The Thread class creates a worker thread capable of dispatching and invoking asynchronous delegates.
| Thread::Thread | ( | const std::string & | threadName, |
| size_t | maxQueueSize = 0 ) |
Constructor
| threadName | Name for the thread |
| maxQueueSize | Max number of messages in queue (0 = Default 20) |
| Thread::~Thread | ( | ) |
| Thread::Thread | ( | const std::string & | threadName, |
| size_t | maxQueueSize = 0 ) |
Constructor
| threadName | Name for the FreeRTOS task |
| maxQueueSize | Max number of messages in queue (0 = Default 20) |
| Thread::~Thread | ( | ) |
Destructor.
| Thread::Thread | ( | const std::string & | threadName | ) |
Constructor
| threadName | Name for debugging (QObject::objectName) |
| Thread::~Thread | ( | ) |
Destructor.
| Thread::Thread | ( | const std::string & | threadName, |
| size_t | maxQueueSize = 0 ) |
Constructor
| threadName | The name of the thread for debugging. |
| maxQueueSize | The maximum number of messages allowed in the queue. 0 means unlimited (no back pressure). |
| Thread::~Thread | ( | ) |
Destructor.
| Thread::Thread | ( | const std::string & | threadName, |
| size_t | maxQueueSize = 0 ) |
Constructor
| threadName | Name for the ThreadX thread |
| maxQueueSize | Max number of messages in queue (0 = Default 20) |
| Thread::~Thread | ( | ) |
Destructor.
| Thread::Thread | ( | const std::string & | threadName, |
| size_t | maxQueueSize = 0 ) |
Constructor
| threadName | The name of the thread for debugging. |
| maxQueueSize | The maximum number of messages allowed in the queue. 0 means unlimited (no back pressure). |
|
virtual |
Destructor.
| Thread::Thread | ( | const std::string & | threadName | ) |
| Thread::~Thread | ( | ) |
| bool Thread::CreateThread | ( | ) |
| bool Thread::CreateThread | ( | ) |
Called once to create the worker thread
| bool Thread::CreateThread | ( | ) |
Create and start the internal QThread.
| bool Thread::CreateThread | ( | ) |
Called once to create the worker thread
| bool Thread::CreateThread | ( | ) |
| bool Thread::CreateThread | ( | std::optional< dmq::Duration > | watchdogTimeout = std::nullopt | ) |
Called once to create the worker thread. If watchdogTimeout value provided, the maximum watchdog interval is used. Otherwise no watchdog.
| [in] | watchdogTimeout | - optional watchdog timeout. |
| bool Thread::CreateThread | ( | std::optional< dmq::Duration > | watchdogTimeout = std::nullopt | ) |
Called once to create the worker thread. If watchdogTimeout value provided, the maximum watchdog interval is used. Otherwise no watchdog.
| [in] | watchdogTimeout | - optional watchdog timeout. |
|
virtual |
Dispatch and invoke a delegate target on the destination thread.
| [in] | msg | - Delegate message containing target function arguments. |
Implements dmq::IThread.
|
overridevirtual |
Enqueues a delegate message for execution on this thread.
This function is called by the source thread (the caller). The implementation must thread-safely transfer ownership of the msg into the target thread's processing queue.
Once the message is received by the target thread's main loop, that loop is responsible for calling IInvoker::Invoke(msg) to actually execute the function.
| [in] | msg | A shared pointer to the delegate message. This pointer must remain valid until the target thread finishes execution. |
Implements dmq::IThread.
|
overridevirtual |
Enqueues a delegate message for execution on this thread.
This function is called by the source thread (the caller). The implementation must thread-safely transfer ownership of the msg into the target thread's processing queue.
Once the message is received by the target thread's main loop, that loop is responsible for calling IInvoker::Invoke(msg) to actually execute the function.
| [in] | msg | A shared pointer to the delegate message. This pointer must remain valid until the target thread finishes execution. |
Implements dmq::IThread.
|
overridevirtual |
Enqueues a delegate message for execution on this thread.
This function is called by the source thread (the caller). The implementation must thread-safely transfer ownership of the msg into the target thread's processing queue.
Once the message is received by the target thread's main loop, that loop is responsible for calling IInvoker::Invoke(msg) to actually execute the function.
| [in] | msg | A shared pointer to the delegate message. This pointer must remain valid until the target thread finishes execution. |
Implements dmq::IThread.
|
overridevirtual |
Enqueues a delegate message for execution on this thread.
This function is called by the source thread (the caller). The implementation must thread-safely transfer ownership of the msg into the target thread's processing queue.
Once the message is received by the target thread's main loop, that loop is responsible for calling IInvoker::Invoke(msg) to actually execute the function.
| [in] | msg | A shared pointer to the delegate message. This pointer must remain valid until the target thread finishes execution. |
Implements dmq::IThread.
|
overridevirtual |
Dispatch and invoke a delegate target on the destination thread.
| [in] | msg | - Delegate message containing target function arguments. |
Implements dmq::IThread.
|
overridevirtual |
Enqueues a delegate message for execution on this thread.
This function is called by the source thread (the caller). The implementation must thread-safely transfer ownership of the msg into the target thread's processing queue.
Once the message is received by the target thread's main loop, that loop is responsible for calling IInvoker::Invoke(msg) to actually execute the function.
| [in] | msg | A shared pointer to the delegate message. This pointer must remain valid until the target thread finishes execution. |
Implements dmq::IThread.
| void Thread::ExitThread | ( | ) |
| void Thread::ExitThread | ( | ) |
Terminate the thread gracefully.
| void Thread::ExitThread | ( | ) |
Stop the QThread.
| void Thread::ExitThread | ( | ) |
Called once at program exit to shut down the worker thread.
| void Thread::ExitThread | ( | ) |
Terminate the thread gracefully.
| void Thread::ExitThread | ( | ) |
Called once at program exit to shut down the worker thread.
| void Thread::ExitThread | ( | ) |
|
static |
|
static |
Get the ID of the currently executing thread.
|
static |
Get the current executing QThread pointer.
|
static |
Get the ID of the currently executing thread.
|
static |
Get the ID of the currently executing thread.
|
static |
Get the ID of the currently executing thread.
|
static |
| size_t Thread::GetQueueSize | ( | ) |
Get size of thread message queue.
| size_t Thread::GetQueueSize | ( | ) |
Get size of thread message queue.
| k_tid_t Thread::GetThreadId | ( | ) |
| TaskHandle_t Thread::GetThreadId | ( | ) |
Get the ID of this thread instance.
| QThread * Thread::GetThreadId | ( | ) |
Get the QThread pointer (used as the ID)
| std::thread::id Thread::GetThreadId | ( | ) |
Get the ID of this thread instance.
| TX_THREAD * Thread::GetThreadId | ( | ) |
Get the ID of this thread instance.
| DWORD Thread::GetThreadId | ( | ) |
Get the ID of this thread instance.
| k_tid_t Thread::GetThreadId | ( | ) |
|
inline |
|
inline |
Get thread name.
|
inline |
Get thread name.
|
inline |
Get thread name.
|
inline |
Get thread name.
|
inline |
|
inline |
| UINT Thread::GetThreadPriority | ( | ) |
Get current priority.
| UINT Thread::GetThreadPriority | ( | ) |
Get current priority.
| void Thread::SetStackMem | ( | StackType_t * | stackBuffer, |
| uint32_t | stackSizeInWords ) |
Optional: Provide a static buffer for the task stack to avoid Heap usage.
| stackBuffer | Pointer to a buffer of type StackType_t. |
| stackSizeInWords | Size of the buffer in WORDS (not bytes). |
| void Thread::SetThreadPriority | ( | int | priority | ) |
Set the FreeRTOS Task Priority. Can be called before or after CreateThread().
| priority | FreeRTOS priority level (0 to configMAX_PRIORITIES-1) |
| void Thread::SetThreadPriority | ( | osPriority_t | priority | ) |
Set the thread priority. Can be called before or after CreateThread().
| void Thread::SetThreadPriority | ( | UINT | priority | ) |
Set the ThreadX Priority (0 = Highest). Can be called before or after CreateThread().
|
signal |
|
static |
Default queue size if 0 is passed.
|
static |
Default queue size if 0 is passed.
|
static |
Default queue size if 0 is passed.