TaskRunner
Inherits:
QObject
Executes queued tasks sequentially using QtConcurrent worker threads.
TaskRunner accepts member functions, free functions, and generic callable wrappers, then runs them one at a time in submission order. Although only one queued task is active at a time, each task executes on a worker thread, so any shared state touched by those tasks must still be synchronized appropriately by the caller.
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
TaskRunner explicit | Constructs a task runner with an optional QObject parent. | |
void | start | Starts processing the queued tasks if execution is not already active. |
void | add inline | Enqueues a member function to be executed later. |
void | add | Enqueues a free or static function to be executed later. |
void | add | Enqueues an arbitrary callable wrapper to be executed later. |
explicit
TaskRunner
Section titled “TaskRunner”Constructs a task runner with an optional QObject parent.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
parent | QObject* | Parent object used for normal Qt ownership semantics. |
Starts processing the queued tasks if execution is not already active.
Calling this function when work is already in progress should leave the existing execution flow unchanged.
inline
Enqueues a member function to be executed later.
If either pointer is null, the request is ignored so the queue only stores valid callable work items.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
context | T* | Object instance on which the member function will be invoked. |
func | void(T::*)() | Pointer to the zero-argument member function to execute. |
Enqueues a free or static function to be executed later.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
func | void(*)() | Pointer to the zero-argument function to execute. |
Enqueues an arbitrary callable wrapper to be executed later.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
lambda | std::function<void()> | Callable object to execute when it reaches the front of the queue. |
Signals
Section titled “Signals”| Return | Name | Description |
|---|---|---|
void | finished | Emitted after the final queued task completes and the queue becomes empty. |
finished
Section titled “finished”Emitted after the final queued task completes and the queue becomes empty.