libqi-api  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions
qi::PeriodicTask Class Reference

#include <periodictask.hpp>

List of all members.

Public Types

typedef boost::function< void()> Callback

Public Member Functions

 PeriodicTask ()
 ~PeriodicTask ()
void setCallback (const Callback &cb)
template<typename T , typename ARG0 >
PeriodicTasksetCallback (const T &callable, ARG0 tracked,...)
void setUsPeriod (qi::int64_t usPeriod)
void start (bool immediate=true)
void stop ()
void asyncStop ()
void compensateCallbackTime (bool compensate)
void setName (const std::string &name)
 Set name for debugging and tracking purpose.
bool isRunning () const
bool isStopping () const

Detailed Description

Control a task executed periodically and asynchronously.

Definition at line 23 of file periodictask.hpp.


Member Typedef Documentation

typedef boost::function<void()> qi::PeriodicTask::Callback

Definition at line 26 of file periodictask.hpp.


Constructor & Destructor Documentation


Member Function Documentation

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.

Returns:
true if task is running
Returns:
whether state is stopping or stopped Can be called from within the callback to know if stop() or asyncStop() was called.

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.

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:
immediateif true, first schedule of the task will happen with no delay.
Warning:
concurrent calls to start() and stop() will result in undefined behavior.

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.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines