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

#include <periodictask.hpp>

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 trigger ()
 
void stop ()
 
void asyncStop ()
 
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 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

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

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.
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
immediateif 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: