#include <TaskScheduler.h>
|
| | SchedulerTask (IExecutor &executor) |
| | Constructor that wraps an IExecutor implementation.
|
| |
| | SchedulerTask (SchedulerTaskCallback callback) |
| | Constructor with custom callback function.
|
| |
| void | attach (uint32_t ms, short times=0) |
| | Attach the task to run on a specified interval.
|
| |
| void | once (uint32_t ms) |
| | Schedule the task to run once after the specified delay.
|
| |
| void | trigger () |
| | Run the task once on the scheduler's next pass.
|
| |
| void | loop () |
| | Main execution loop for the task.
|
| |
| uint64_t | getTotalElapsedMs () const |
| | Get the total execution time of this task in milliseconds.
|
| |
| | ESP8266Task () |
| | Constructor.
|
| |
| virtual | ~ESP8266Task () |
| | Destructor that ensures the timer is detached.
|
| |
| void | attach (uint32_t ms, bool repeat, TaskCallback callback) |
| | Attach a simple callback to run periodically.
|
| |
| template<typename T> |
| void | attach (uint32_t ms, bool repeat, TaskTypeCallback< volatile T > callback, volatile T arg) |
| | Attach a typed callback with argument to run periodically.
|
| |
| void | detach () |
| | Stop and detach the timer.
|
| |
| bool | isAttached () |
| | Check if the timer is attached.
|
| |
◆ SchedulerTaskCallback
Callback function signature for scheduled tasks.
- Parameters
-
| task | Reference to the executing task |
| times | Number of repetitions left (-1 for infinite) |
◆ spSchedulerTaskCallback
Shared pointer type for task callbacks.
◆ SchedulerTask() [1/2]
| uniot::SchedulerTask::SchedulerTask |
( |
IExecutor & | executor | ) |
|
|
inline |
Constructor that wraps an IExecutor implementation.
- Parameters
-
| executor | The executor to be called when the task runs |
◆ SchedulerTask() [2/2]
Constructor with custom callback function.
- Parameters
-
| callback | Function to execute when the task runs |
◆ attach()
| void uniot::SchedulerTask::attach |
( |
uint32_t | ms, |
|
|
short | times = 0 ) |
|
inline |
Attach the task to run on a specified interval.
- Parameters
-
| ms | Millisecond interval between executions |
| times | Number of times to execute (0 or negative for infinite) |
◆ getTotalElapsedMs()
| uint64_t uniot::SchedulerTask::getTotalElapsedMs |
( |
| ) |
const |
|
inline |
Get the total execution time of this task in milliseconds.
- Return values
-
| time | Total elapsed time in milliseconds |
◆ loop()
| void uniot::SchedulerTask::loop |
( |
| ) |
|
|
inline |
Main execution loop for the task.
Checks if the task is ready to execute and runs the callback if so. Tracks execution time and manages repeat counts.
◆ once()
| void uniot::SchedulerTask::once |
( |
uint32_t | ms | ) |
|
|
inline |
Schedule the task to run once after the specified delay.
- Parameters
-
| ms | Millisecond delay before execution |
◆ trigger()
| void uniot::SchedulerTask::trigger |
( |
| ) |
|
|
inline |
Run the task once on the scheduler's next pass.
Sets the same flag the task's timer sets when it fires, and nothing else, so it can be called from contexts where scheduler work is unsafe: an SDK callback running inside yield(), or another FreeRTOS task. The work itself still runs from TaskScheduler::loop(). The timer is deliberately left alone – on ESP32 attaching creates and deletes it, which two contexts arming the same task at once would race.
Triggers that arrive before the next pass run the callback once. It receives the remaining repetitions as usual: 0 for a task that was never attached, and on a task attached with a repeat count the triggered run counts as one of them. A task that is only ever triggered must be pushed under a name, since the scheduler drops unnamed tasks that are not attached.
The documentation for this class was generated from the following file: