- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
qi::PeriodicTask Class Reference

Control a task executed periodically and asynchronously. . More...

`#include <periodictask.hpp>`

## Public Types
using | Callback = boost::function< void()>
| Callback is a boost::function. More...

## Public Member Functions
| PeriodicTask ()
| Default constructor. More...
| ~PeriodicTask ()
| Default destructor. More...
template<typename T >
auto | setCallback (T &&cb) -> typename std::enable_if< detail::IsAsyncBind< typename std::decay< T >::type >::value >::type
template<typename T >
auto | setCallback (T &&cb) -> typename std::enable_if<!detail::IsAsyncBind< typename std::decay< T >::type >::value >::type
template<typename AF , typename ARG0 , typename... ARGS>
void | setCallback (AF &&callable, ARG0 &&arg0, ARGS &&...args)
void | setStrand (qi::Strand *strand)
void | setUsPeriod (qi::int64_t usPeriod)
| Set the call interval in microseconds. More...
void | setPeriod (qi::Duration period)
| Set the call interval. More...
void | start (bool immediate=true)
| Start the periodic task at specified period. More...
void | trigger ()
void | stop ()
| Stop the periodic task. More...
void | asyncStop ()
| Request for periodic task to stop asynchronously. Can be safely called from within the callback. More...
void | compensateCallbackTime (bool compensate)
void | setName (const std::string &name)
| Set name for debugging and tracking purpose. More...
bool | isRunning () const
bool | isStopping () const

## Detailed Description

Control a task executed periodically and asynchronously. .

Definition at line 27 of file periodictask.hpp.

## Member Typedef Documentation

using qi::PeriodicTask::Callback = boost::function<void()>

Callback is a boost::function.

Definition at line 31 of file periodictask.hpp.

## Constructor & Destructor Documentation

qi::PeriodicTask::PeriodicTask | ( |  | ) |

Default constructor.

qi::PeriodicTask::~PeriodicTask | ( |  | ) |

Default destructor.

## Member Function Documentation

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

Definition at line 52 of file periodictask.hpp.

template<typename AF , typename ARG0 , typename... ARGS>

void qi::PeriodicTask::setCallback | ( | AF && | callable,
|  | ARG0 && | arg0,
|  | ARGS &&... | args
| ) |  |
| inline

Definition at line 57 of file periodictask.hpp.

void qi::PeriodicTask::setName | ( | const std::string & | name | ) |

Set name for debugging and tracking purpose.

Parameters

  name | Name of the periodic task.

void qi::PeriodicTask::setPeriod | ( | qi::Duration | period | ) |

Set the call interval.

Parameters

  period | the PeriodicTask period

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:

- /home/opennao/work/release-2.8/sdk/libqi/qi/periodictask.hpp