Sirikata
Public Member Functions | Private Member Functions | Private Attributes
Sirikata::Poller Class Reference

Poller allows you to generate a callback periodically without having to inherit from the PollingService class. More...

#include <Poller.hpp>

Inheritance diagram for Sirikata::Poller:
Collaboration diagram for Sirikata::Poller:

List of all members.

Public Member Functions

 Poller (Network::IOStrand *str, const Network::IOCallback &cb, const char *cb_tag, const Duration &max_rate=Duration::microseconds(0), bool accurate=false)
virtual ~Poller ()
virtual void start ()
 Start polling this service on this strand at the given maximum rate.
virtual void stop ()
 Stop scheduling this service.

Private Member Functions

void setupNextTimeout (const Duration &user_time)
void handleExec (const Network::IOTimerWPtr &timer)

Private Attributes

Network::IOStrandmStrand
Network::IOTimerPtr mTimer
Duration mMaxRate
bool mAccurate
bool mUnschedule
Network::IOCallback mCB
Network::IOCallback mUserCB
const char * mCBTag

Detailed Description

Poller allows you to generate a callback periodically without having to inherit from the PollingService class.

It serves the same function but requires a new object for every callback instead of using an existing service.

Normally, the rate of invocations is approximate and essentially assumes that your callback will execute very quickly. You can also use a more accurate mode that tries to account for the time spent in your callback and tries to consistently trigger your callback at the requested period. Even with the 'accurate' setting, you're still subject to delays due to the event queue and imprecision from the timer. Further, there is overhead for timing the user callback. The inaccurate version will only invoke callbacks at a slower rate, and usually not by much, so you should only use this in special circumstances.


Constructor & Destructor Documentation

Sirikata::Poller::Poller ( Network::IOStrand str,
const Network::IOCallback cb,
const char *  cb_tag,
const Duration max_rate = Duration::microseconds(0),
bool  accurate = false 
)
Sirikata::Poller::~Poller ( ) [virtual]

Member Function Documentation

void Sirikata::Poller::handleExec ( const Network::IOTimerWPtr timer) [private]
void Sirikata::Poller::setupNextTimeout ( const Duration user_time) [private]
void Sirikata::Poller::start ( ) [virtual]
void Sirikata::Poller::stop ( ) [virtual]

Member Data Documentation

Referenced by handleExec().

Reimplemented in Sirikata::TimeSyncClient.

Referenced by Poller(), setupNextTimeout(), and start().

const char* Sirikata::Poller::mCBTag [private]

Referenced by setupNextTimeout(), start(), stop(), and ~Poller().

Referenced by setupNextTimeout().

Referenced by Poller(), setupNextTimeout(), and start().

Referenced by Poller(), and setupNextTimeout().

Referenced by handleExec(), and stop().

Referenced by handleExec().


The documentation for this class was generated from the following files: