Executes a queue of callback functions sequentially on a dedicated thread.
More...
|
| | ThreadQueue (const String &name) |
| | Constructs a ThreadQueue with the given name.
|
| void | add (const std::function< void()> &callback) |
| | Adds a callback function to the queue and starts the thread if not already running.
|
|
void | run () override |
| | Executes all queued functions sequentially in the thread.
|
|
| Thread () |
| | Constructs a Thread with a default name.
|
| | Thread (const StringView &name) |
| | Constructs a Thread with the specified name.
|
|
virtual | ~Thread () |
| | Destroys the Thread and cleans up resources.
|
|
void | detach () |
| | Detaches the thread, allowing it to run independently.
|
|
void | forceStop () |
| | Forces the running flag to false without waiting for the thread to finish.
|
| bool | isPrimaryThread () const |
| | Checks whether this thread is the primary thread.
|
| bool | isRunning () const |
| | Checks whether the thread is currently running.
|
|
void | join () |
| | Blocks the calling thread until this thread finishes execution.
|
|
virtual void | requestStopThread () |
| | Requests the thread to stop without blocking.
|
| void | setIsPrimaryThread (bool is_primary_thread) |
| | Sets whether this thread should be treated as the primary thread.
|
| void | setThreadName (const StringView &name) |
| | Sets the name of this thread.
|
| virtual bool | shouldExitThread () const |
| | Checks whether the thread has been requested to exit.
|
|
void | start () |
| | Starts the thread execution.
|
|
virtual void | stopThread () |
| | Stops the thread and waits for it to finish.
|
| const String & | threadName () const |
| | Gets the name assigned to this thread.
|
|
|
Resource< bool > | sv_is_running |
| | Indicates whether the thread queue is currently running.
|
|
|
std::function< void(const char *const)> | m_error_callback |
| | Optional callback invoked when an error occurs during execution.
|
|
Buffer< std::function< void()> > | m_functions |
| | The queue of functions awaiting execution.
|
|
volatile bool | m_is_running = false |
| | Whether the thread is currently running.
|
|
volatile bool | m_is_single_run = true |
| | Whether the thread should execute only once before stopping.
|
|
| static Thread & | CurrentThread () |
| | Gets a reference to the Thread object for the calling thread.
|
| static String | CurrentThreadName () |
| | Gets the name of the current thread.
|
|
static void | ServiceVirtualThreads () |
| | Services any virtual threads that require periodic execution.
|
| static void | SetCurrentThreadName (const StringView &name) |
| | Sets the name of the current thread.
|
|
static void | StopAllThreads () |
| | Stops all tracked threads.
|
| const std::thread & | self () |
| | Gets a const reference to the underlying std::thread.
|
Executes a queue of callback functions sequentially on a dedicated thread.
- See also
- Thread, BasicThread
Definition at line 44 of file ThreadQueue.h.
◆ ThreadQueue()
| ThreadQueue::ThreadQueue |
( |
const String & | name | ) |
|
|
explicit |
Constructs a ThreadQueue with the given name.
- Parameters
-
| [in] | name | The name to assign to this thread queue. |
◆ add()
| void ThreadQueue::add |
( |
const std::function< void()> & | callback | ) |
|
|
inline |
Adds a callback function to the queue and starts the thread if not already running.
- Parameters
-
| [in] | callback | The function to enqueue for execution. |
Definition at line 64 of file ThreadQueue.h.
References m_functions, and Thread::start().
The documentation for this class was generated from the following file: