#include <scheduler.h>
Public Member Functions | |
TaskStep (time_t step, time_t shift, modules::Module *module, std::string const &name="", std::string const &desc="") | |
Constructor. | |
TaskStep (TaskStep const &t) | |
Copy constructor. | |
TaskStep & | operator= (TaskStep const &right) |
Assignment operator. | |
virtual bool | poll () |
Returns true and when the interval has elapsed. | |
time_t | step () const |
Returns the interval between two runs, in seconds. | |
time_t | step (time_t step) |
Sets the interval between two runs. | |
time_t | shift () const |
Returns the shift, in seconds. | |
time_t | shift (time_t shift) |
Sets the shift. | |
time_t | next () const |
Returns when the task will run next time. | |
Protected Attributes | |
time_t | m_step |
Interval between two runs. | |
time_t | m_shift |
Shift. | |
time_t | m_next |
When must the task run next? |
The main difference with other similar classes, such as TaskTimeout, is that the base time is midnight of the day the task has been created.
So, for example, if you create a task of this type at 1pm that must run every four hours, it will be run at 4pm and 8pm of the same day, and at 12am, 4am, 8am, 12pm, 4pm and 8pm of the next days until it is removed.
You can also set a shift that will modify the behaviour of the class. For example, a 7200 seconds shift for the task described above will make it run at 2am, 6am, 10am, 2pm, 6pm and 10pm.
scheduler::TaskStep::TaskStep | ( | time_t | step, | |
time_t | shift, | |||
modules::Module * | module, | |||
std::string const & | name = "" , |
|||
std::string const & | desc = "" | |||
) |
Sets the task type, step and shift (see the class description for more details).
[in] | step | The interval between two runs, in seconds. |
[in] | shift | The shift, in seconds (must be less than step). |
[in] | module | The module this task belongs to. |
[in] | name | The name of the task, used by some functions who act on tasks by name. Set that if you don't intend to override the name() function. |
[in] | desc | An arbitrary description of the task. Set that if you don't intend to * override the description() function. |
time_t scheduler::TaskStep::step | ( | time_t | step | ) |
Sets the interval between two runs.
[in] | step | The new interval between two runs, in seconds. |
time_t scheduler::TaskStep::shift | ( | time_t | shift | ) |
Sets the shift.
[in] | shift | The new shift. |