Control a task executed periodically and asynchronously. .
More...
#include <periodictask.hpp>
|
using | Callback = boost::function< void()> |
| Callback is a boost::function. More...
|
|
Control a task executed periodically and asynchronously. .
Definition at line 27 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.
template<typename T >
auto qi::PeriodicTask::setCallback |
( |
T && |
cb | ) |
-> typename std::enable_if<detail::IsAsyncBind<typename std::decay<T>::type>::value>::type
|
|
inline |
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
Definition at line 46 of file periodictask.hpp.
template<typename T >
auto qi::PeriodicTask::setCallback |
( |
T && |
cb | ) |
-> typename std::enable_if<!detail::IsAsyncBind<typename std::decay<T>::type>::value>::type
|
|
inline |
template<typename AF , typename ARG0 , typename... ARGS>
void qi::PeriodicTask::setCallback |
( |
AF && |
callable, |
|
|
ARG0 && |
arg0, |
|
|
ARGS &&... |
args |
|
) |
| |
|
inline |
void qi::PeriodicTask::setName |
( |
const std::string & |
name | ) |
|
Set name for debugging and tracking purpose.
- Parameters
-
name | Name of the periodic task. |
Set the call interval.
- Parameters
-
This call will wait until next callback invocation to apply the change. If you call this function from within the callback, it will be taken into account immediately.
void qi::PeriodicTask::setStrand |
( |
qi::Strand * |
strand | ) |
|
Set the strand on which to schedule the calls
- Warning
- This must be called after the call to setCallback or it will have no effect.
void qi::PeriodicTask::setUsPeriod |
( |
qi::int64_t |
usPeriod | ) |
|
Set the call interval in microseconds.
- Deprecated:
- since 2.3. Use setPeriod.
void qi::PeriodicTask::start |
( |
bool |
immediate = true | ) |
|
Start the periodic task at specified period.
No effect if already running. No effect if called from within the callback.
- 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: