OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Timer Class Reference

#include <timer.h>

Collaboration diagram for Timer:

Classes

class  TimerTask
 

Public Types

typedef boost::function< bool(void)> Handler
 
typedef boost::function< void(std::string,
std::string, std::string)> 
ErrorHandler
 

Public Member Functions

 Timer (boost::asio::io_context &service, const std::string &name, int task_id, int task_instance, bool delete_on_completion=false)
 
virtual ~Timer ()
 
bool Start (int time, Handler handler, ErrorHandler error_handler=NULL)
 
bool Reschedule (int time)
 
bool Cancel ()
 
bool running () const
 
bool fired () const
 
int time () const
 
bool cancelled () const
 
bool Idle () const
 
bool IsDeleteOnCompletion () const
 
int64_t GetElapsedTime () const
 
void Fire ()
 
virtual std::string Description ()
 

Private Types

enum  TimerState { Init = 0, Running = 1, Fired = 2, Cancelled = 3 }
 
typedef boost::intrusive_ptr
< Timer
TimerPtr
 

Private Member Functions

void StartTimerTask (TimerPtr reference, int time, uint32_t seq_no, const boost::system::error_code &ec)
 
void SetState (TimerState s)
 

Static Private Member Functions

static int GetTimerInstanceId ()
 
static int GetTimerTaskId ()
 

Private Attributes

boost::scoped_ptr< TimerImplimpl_
 
std::string name_
 
Handler handler_
 
ErrorHandler error_handler_
 
tbb::mutex mutex_
 
TimerState state_
 
TimerTasktimer_task_
 
int time_
 
int task_id_
 
int task_instance_
 
uint32_t seq_no_
 
bool delete_on_completion_
 
tbb::atomic< int > refcount_
 

Friends

class TimerManager
 
class TimerTest
 
void intrusive_ptr_add_ref (Timer *timer)
 
void intrusive_ptr_release (Timer *timer)
 

Detailed Description

Definition at line 54 of file timer.h.

Member Typedef Documentation

typedef boost::function<void(std::string, std::string, std::string)> Timer::ErrorHandler

Definition at line 62 of file timer.h.

typedef boost::function<bool(void)> Timer::Handler

Definition at line 57 of file timer.h.

typedef boost::intrusive_ptr<Timer> Timer::TimerPtr
private

Definition at line 136 of file timer.h.

Member Enumeration Documentation

enum Timer::TimerState
private
Enumerator
Init 
Running 
Fired 
Cancelled 

Definition at line 138 of file timer.h.

Constructor & Destructor Documentation

Timer::Timer ( boost::asio::io_context &  service,
const std::string &  name,
int  task_id,
int  task_instance,
bool  delete_on_completion = false 
)

Definition at line 83 of file timer.cc.

Timer::~Timer ( )
virtual

Definition at line 99 of file timer.cc.

Member Function Documentation

bool Timer::Cancel ( )

Definition at line 150 of file timer.cc.

Here is the call graph for this function:

bool Timer::cancelled ( ) const
inline

Definition at line 100 of file timer.h.

virtual std::string Timer::Description ( )
inlinevirtual

Definition at line 127 of file timer.h.

void Timer::Fire ( )
inline

Definition at line 118 of file timer.h.

Here is the call graph for this function:

bool Timer::fired ( ) const
inline

Definition at line 91 of file timer.h.

int64_t Timer::GetElapsedTime ( ) const

Definition at line 235 of file timer.cc.

static int Timer::GetTimerInstanceId ( )
inlinestaticprivate

Definition at line 151 of file timer.h.

static int Timer::GetTimerTaskId ( )
inlinestaticprivate

Definition at line 152 of file timer.h.

Here is the call graph for this function:

bool Timer::Idle ( ) const
inline

Definition at line 105 of file timer.h.

bool Timer::IsDeleteOnCompletion ( ) const
inline

Definition at line 110 of file timer.h.

bool Timer::Reschedule ( int  time)

Definition at line 137 of file timer.cc.

Here is the call graph for this function:

bool Timer::running ( ) const
inline

Definition at line 86 of file timer.h.

void Timer::SetState ( TimerState  s)
inlineprivate

Definition at line 150 of file timer.h.

bool Timer::Start ( int  time,
Handler  handler,
ErrorHandler  error_handler = NULL 
)

Definition at line 108 of file timer.cc.

Here is the call graph for this function:

void Timer::StartTimerTask ( TimerPtr  reference,
int  time,
uint32_t  seq_no,
const boost::system::error_code &  ec 
)
private

Definition at line 172 of file timer.cc.

Here is the call graph for this function:

int Timer::time ( ) const
inline

Definition at line 96 of file timer.h.

Friends And Related Function Documentation

void intrusive_ptr_add_ref ( Timer timer)
friend

Definition at line 177 of file timer.h.

void intrusive_ptr_release ( Timer timer)
friend

Definition at line 181 of file timer.h.

friend class TimerManager
friend

Definition at line 131 of file timer.h.

friend class TimerTest
friend

Definition at line 132 of file timer.h.

Member Data Documentation

bool Timer::delete_on_completion_
private

Definition at line 173 of file timer.h.

ErrorHandler Timer::error_handler_
private

Definition at line 165 of file timer.h.

Handler Timer::handler_
private

Definition at line 164 of file timer.h.

boost::scoped_ptr<TimerImpl> Timer::impl_
private

Definition at line 162 of file timer.h.

tbb::mutex Timer::mutex_
mutableprivate

Definition at line 166 of file timer.h.

std::string Timer::name_
private

Definition at line 163 of file timer.h.

tbb::atomic<int> Timer::refcount_
private

Definition at line 174 of file timer.h.

uint32_t Timer::seq_no_
private

Definition at line 172 of file timer.h.

TimerState Timer::state_
private

Definition at line 167 of file timer.h.

int Timer::task_id_
private

Definition at line 170 of file timer.h.

int Timer::task_instance_
private

Definition at line 171 of file timer.h.

int Timer::time_
private

Definition at line 169 of file timer.h.

TimerTask* Timer::timer_task_
private

Definition at line 168 of file timer.h.


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