Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::SchedulerTask Class Reference

#include <TaskScheduler.h>

Inheritance diagram for uniot::SchedulerTask:
[legend]

Public Types

using SchedulerTaskCallback = std::function<void(SchedulerTask &, short)>
 Callback function signature for scheduled tasks.
 
using spSchedulerTaskCallback = SharedPointer<SchedulerTaskCallback>
 Shared pointer type for task callbacks.
 
- Public Types inherited from uniot::ESP8266Task
using TaskCallback = void (*)(void)
 Callback function with no arguments.
 
using TaskArgCallback = void (*)(void *)
 Callback function with void pointer argument.
 
template<typename T>
using TaskTypeCallback = void (*)(volatile T)
 Templated callback function with typed argument.
 

Public Member Functions

 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 loop ()
 Main execution loop for the task.
 
uint64_t getTotalElapsedMs () const
 Get the total execution time of this task in milliseconds.
 
- Public Member Functions inherited from uniot::ESP8266Task
 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.
 

Member Typedef Documentation

◆ SchedulerTaskCallback

using uniot::SchedulerTask::SchedulerTaskCallback = std::function<void(SchedulerTask &, short)>

Callback function signature for scheduled tasks.

Parameters
taskReference to the executing task
timesNumber of repetitions left (-1 for infinite)

◆ spSchedulerTaskCallback

Shared pointer type for task callbacks.

Constructor & Destructor Documentation

◆ SchedulerTask() [1/2]

uniot::SchedulerTask::SchedulerTask ( IExecutor & executor)
inline

Constructor that wraps an IExecutor implementation.

Parameters
executorThe executor to be called when the task runs

◆ SchedulerTask() [2/2]

uniot::SchedulerTask::SchedulerTask ( SchedulerTaskCallback callback)
inline

Constructor with custom callback function.

Parameters
callbackFunction to execute when the task runs

Member Function Documentation

◆ attach()

void uniot::SchedulerTask::attach ( uint32_t ms,
short times = 0 )
inline

Attach the task to run on a specified interval.

Parameters
msMillisecond interval between executions
timesNumber 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
timeTotal 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
msMillisecond delay before execution

The documentation for this class was generated from the following file: