#include <periodictask.hpp>
|
typedef boost::function< void()> | Callback |
|
Control a task executed periodically and asynchronously.
Definition at line 23 of file periodictask.hpp.
qi::PeriodicTask::PeriodicTask |
( |
| ) |
|
qi::PeriodicTask::~PeriodicTask |
( |
| ) |
|
void qi::PeriodicTask::asyncStop |
( |
| ) |
|
Request for periodic task to stop asynchronously. Can be safely called from within the callback.
void qi::PeriodicTask::compensateCallbackTime |
( |
bool |
compensate | ) |
|
If argument is true, call interval will take into account call duration to maintain the period.
bool qi::PeriodicTask::isRunning |
( |
| ) |
const |
- Returns
- true if task is running
bool qi::PeriodicTask::isStopping |
( |
| ) |
const |
- Returns
- whether state is stopping or stopped Can be called from within the callback to know if stop() or asyncStop() was called.
void qi::PeriodicTask::setCallback |
( |
const Callback & |
cb | ) |
|
One of the setCallback() functions below must be called before any other operation. Once set the callback cannot be changed. If the callback throws, async task will be stopped
template<typename T , typename ARG0 >
PeriodicTask& qi::PeriodicTask::setCallback |
( |
const T & |
callable, |
|
|
ARG0 |
tracked, |
|
|
|
... |
|
) |
| |
void qi::PeriodicTask::setName |
( |
const std::string & |
name | ) |
|
Set name for debugging and tracking purpose.
void qi::PeriodicTask::setUsPeriod |
( |
qi::int64_t |
usPeriod | ) |
|
Set the call interval in microseconds. This call will wait until next callback invocation to apply the change. Use: task.stop(); task.setUsPeriod() task.start() to apply the change immediately.
void qi::PeriodicTask::start |
( |
bool |
immediate = true | ) |
|
Start the periodic task at specified period. No effect if already running.
- Parameters
-
immediate | if true, first schedule of the task will happen with no delay. |
- Warning
- concurrent calls to start() and stop() will result in undefined behavior.
void qi::PeriodicTask::stop |
( |
| ) |
|
Stop the periodic task. When this function returns, the callback will not be called anymore. Can be called from within the callback function.
- Warning
- concurrent calls to start() and stop() will result in undefined behavior.
void qi::PeriodicTask::trigger |
( |
| ) |
|
Trigger a started periodic task to run right now. Does nothing if the periodic task just ran, is running, starting, stopping or stopped.
The documentation for this class was generated from the following file: