wavelength 1.0.0
Loading...
Searching...
No Matches
periodictask.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "os/task.h"
6
13public:
15 static constexpr float kNever = 1.0e30f;
16
24 explicit PeriodicTask(float fPeriod);
25
33
41 void SetTask(Task *pTask);
42
50 int Poll();
51
58 void RunNow();
59
66 void Suspend();
67
69 Task *GetTask() const {
70 return mTask.get();
71 }
72
74 float GetPeriod() const {
75 return mPeriod;
76 }
77
79 float GetNextTime() const {
80 return mNextTime;
81 }
82
88 void SetNextTime(float fNextTime) {
89 mNextTime = fNextTime;
90 }
91
92private:
93 std::unique_ptr<Task> mTask;
94 float mPeriod;
95 float mNextTime;
96};
int Poll()
Start the task once its time comes, poll it, and schedule the next run once it ends.
void Suspend()
Stop the schedule from starting the task.
void SetTask(Task *pTask)
Set the task, which the schedule then deletes.
void RunNow()
Run the task at the next Poll().
static constexpr float kNever
The time a schedule that waits for nothing records.
Definition periodictask.h:15
~PeriodicTask()
Stop and delete the task.
float GetNextTime() const
Definition periodictask.h:79
Task * GetTask() const
Definition periodictask.h:69
float GetPeriod() const
Definition periodictask.h:74
void SetNextTime(float fNextTime)
Set when the task starts next.
Definition periodictask.h:88
PeriodicTask(float fPeriod)
Construct a schedule with no task.
Unit of work an owner starts, polls until it reports that it is done, and stops.
Definition task.h:9