3 #define PQRST_H_LOADED 1 14 #ifndef PQRST_SELF_QUEUE 22 #define PQRST_SELF_QUEUE 0 25 #ifndef PQRST_TASK_PRIORITIES 39 #define PQRST_TASK_PRIORITIES 0 42 #ifndef PQRST_TASK_IDENT 52 #define PQRST_TASK_IDENT 0 70 typedef uint32_t
ms_t;
76 #if !ARDUINO && !defined(MS_FMT) 83 #include <avr/pgmspace.h> 91 #define PQRST_NEXT_UNQUEUED_ reinterpret_cast<Task*>(1) 170 virtual void start(
void);
178 TaskQueue* queue(
void)
const {
return queue_; };
222 #if PQRST_TASK_PRIORITIES 268 friend class ModularTimeMinder;
312 int set_repeats(
int n);
464 void signal_to_task1(
Task*,
int);
466 ModularTimeMinder modtime_minder;
474 bool queue_is_valid_p(
void)
const;
480 bool is_empty(
void)
const;
481 unsigned int size(
bool inc_maintenance=
false)
const;
484 void dump_queue_contents(
void);
486 void initialise(
ms_t start_reftime=0);
488 bool run_ready(
ms_t);
489 ms_t next_due_after(
void)
const;
491 void remove_all_tasks(
void);
496 void push_immediately(
Task*);
498 int lateness(
ms_t)
const;
510 ms_t modtime(
ms_t t)
const {
return t ^ modtime_minder.fix; };
517 #if !PQRST_SELF_QUEUE const ms_t TIME_NEVER
TIME_NEVER is a time which will never happen.
Definition: pqrst.h:106
void(* run_task_t)(ms_t t)
The type of the function which can be supplied to a FunctionTask.
Definition: pqrst.h:346
Task()
Construct a task.
Definition: pqrst.cpp:882
bool user_task_p(void) const
Indicates whether this is a user task or a maintenance task.
Definition: pqrst.h:283
ms_t ready_after(void) const
Return the interval until the Task is next ready, relative to the queue reference time...
Definition: pqrst.cpp:595
virtual void run(ms_t t)=0
Runs one step of the task.
A task which runs a supplied function at a given time.
Definition: pqrst.h:356
ms_t get_cadence(void) const
Return the interval between loop runs.
Definition: pqrst.h:319
TaskQueue Queue
The global TaskQueue.
Definition: pqrst.cpp:1439
ms_t cancel(void)
Cancel this task.
Definition: pqrst.cpp:1027
void set_duration(ms_t)
Set the duration of the task.
Definition: pqrst.cpp:1206
unsigned char get_priority(void) const
Return the priority of the task.
Definition: pqrst.cpp:1189
There are a few ‘maintenance tasks’ on the queue, placed there by the queueing system.
Definition: pqrst.h:267
static const PROGMEM char *const pqrst_version
Reports the PQRST version and compilation options.
Definition: pqrst.h:134
virtual bool user_task_p(void) const
True if this is a ‘user task’, as opposed to a maintenance task.
Definition: pqrst.h:236
void set_task_ident(const char *ident_string)
Set the identification string for a task.
Definition: pqrst.h:247
void run_at(ms_t t, Task *T=nullptr)
Push a new task onto the queue, due at a given time.
Definition: pqrst.cpp:976
bool before(const Task *) const
Impose an ordering on tasks.
Definition: pqrst.cpp:182
int get_repeats(void) const
Returns the number of repeats still to do.
Definition: pqrst.h:326
void run_immediately(Task *T=nullptr)
Push a task onto the queue, due immediately.
Definition: pqrst.cpp:1012
uint32_t ms_t
The Arduino supports a time type of unsigned long, which is a 4-byte unsigned integer on that platfor...
Definition: pqrst.h:58
bool is_enqueued_p(void) const
Return true if the task is currently scheduled on a queue.
Definition: pqrst.h:218
A Task which will automatically reschedule itself after it is run.
Definition: pqrst.h:289
const char * get_task_ident(void) const
Retrieve the identification string.
Definition: pqrst.h:256
virtual void start(void)
Start the task immediately.
Definition: pqrst.cpp:952
bool get_task_slippy(void) const
Determine whether a task is ‘slippy’.
Definition: pqrst.cpp:265
void run_after(ms_t t, Task *T=nullptr)
Push a new Task onto the queue, due some (non-negative) interval after the queue's current reference ...
Definition: pqrst.cpp:998
virtual void run_task(ms_t)
Run this task; this is the method which is actually called when a task is due to be run...
Definition: pqrst.cpp:1129
A Task represents a block of code to be executed at some point in the future.
Definition: pqrst.h:126
void set_priority(unsigned char)
Set the priority of the task.
Definition: pqrst.cpp:1172
ms_t get_duration(void) const
Return the task's expected duration.
Definition: pqrst.cpp:1222
virtual void signal(int signal, ms_t t)
Receive a signal.
Definition: pqrst.cpp:1111
bool set_task_slippy(bool)
Set a task to be ‘slippy’.
Definition: pqrst.cpp:247
ms_t uncancel(void)
Uncancel a task.
Definition: pqrst.cpp:1062
friend class TaskQueue
Definition: pqrst.h:127
void(* traverse_queue_cb_t)(ms_t due, const char *ident, const Task *T)
The type of the callback for TaskQueue::traverse_queue.
Definition: pqrst.h:384
virtual ~Task()
Definition: pqrst.h:167
A priority queue of Tasks.
Definition: pqrst.h:458