ardour
Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
PBD::Timer Class Referenceabstract

#include <timer.h>

Inheritance diagram for PBD::Timer:
PBD::BlinkTimer PBD::StandardTimer

Public Member Functions

 Timer (unsigned int interval, const Glib::RefPtr< Glib::MainContext > &main_context)
 
unsigned int get_interval () const
 
void set_interval (unsigned int new_interval)
 
virtual unsigned int connection_count () const =0
 

Protected Member Functions

virtual ~Timer ()
 
void start ()
 
void stop ()
 
virtual bool on_elapsed ()=0
 

Private Member Functions

 Timer (const Timer &)
 
Timeroperator= (const Timer &)
 
bool timeout_handler ()
 

Static Private Member Functions

static gboolean _timeout_handler (void *data)
 

Private Attributes

GSource * m_timeout_source
 
unsigned int m_timeout_interval
 
const Glib::RefPtr
< Glib::MainContext > 
m_main_context
 

Detailed Description

The Timer class is a wrapper around Glib TimeoutSources The Timer will start automatically when the first connection is made and stop when the last callback is disconnected.

Definition at line 36 of file timer.h.

Constructor & Destructor Documentation

PBD::Timer::Timer ( unsigned int  interval,
const Glib::RefPtr< Glib::MainContext > &  main_context 
)

Definition at line 24 of file timer.cc.

virtual PBD::Timer::~Timer ( )
inlineprotectedvirtual

Definition at line 51 of file timer.h.

PBD::Timer::Timer ( const Timer )
private

Member Function Documentation

gboolean PBD::Timer::_timeout_handler ( void *  data)
staticprivate

Definition at line 34 of file timer.cc.

virtual unsigned int PBD::Timer::connection_count ( ) const
pure virtual

Implemented in PBD::BlinkTimer, and PBD::StandardTimer.

unsigned int PBD::Timer::get_interval ( ) const

Definition at line 41 of file timer.cc.

virtual bool PBD::Timer::on_elapsed ( )
protectedpure virtual

Implemented in PBD::BlinkTimer, and PBD::StandardTimer.

Timer& PBD::Timer::operator= ( const Timer )
private
void PBD::Timer::set_interval ( unsigned int  new_interval)

Definition at line 47 of file timer.cc.

void PBD::Timer::start ( void  )
protected

We don't use Glibmm::TimeoutSource::create() here as contrary to the documentation, SignalTimeout::connect and manually adding a TimeoutSource to a GMainContext are not equivalent.

SignalTimeout::connect is the equivalent of g_timeout_add in terms off callback timing but TimeoutSource tries to adjust the timeout based on the time elapsed since the last timeout.

On Windows with a high frequency timeout(40ms) this causes a small but noticable increase in CPU Usage.

Definition at line 69 of file timer.cc.

void PBD::Timer::stop ( void  )
protected

Definition at line 87 of file timer.cc.

bool PBD::Timer::timeout_handler ( )
private

Definition at line 97 of file timer.cc.

Member Data Documentation

const Glib::RefPtr<Glib::MainContext> PBD::Timer::m_main_context
private

Definition at line 74 of file timer.h.

unsigned int PBD::Timer::m_timeout_interval
private

Definition at line 72 of file timer.h.

GSource* PBD::Timer::m_timeout_source
private

Definition at line 70 of file timer.h.


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