E-MailRelay
Public Types | Public Member Functions | List of all members
GNet::Timer< T > Class Template Reference

A timer class template in which the timeout is delivered to the specified method. More...

#include <gtimer.h>

+ Inheritance diagram for GNet::Timer< T >:
+ Collaboration diagram for GNet::Timer< T >:

Public Types

using method_type = void(T::*)()
 

Public Member Functions

 Timer (T &t, method_type m, EventState)
 Constructor. More...
 
void startTimer (unsigned int interval_s, unsigned int interval_us=0U)
 Starts or restarts the timer so that it expires after the given interval. More...
 
void startTimer (const G::TimeInterval &)
 Starts or restarts the timer so that it expires after the given interval. More...
 
void cancelTimer ()
 Cancels the timer. Does nothing if not running. More...
 
bool active () const noexcept
 Returns true if the timer is running. More...
 
 Timer (const Timer< T > &)=delete
 
 Timer (Timer< T > &&)=delete
 
Timer< T > & operator= (const Timer< T > &)=delete
 
Timer< T > & operator= (Timer< T > &&)=delete
 

Detailed Description

template<typename T>
class GNet::Timer< T >

A timer class template in which the timeout is delivered to the specified method.

Any exception thrown out of the timeout handler is delivered to the specified ExceptionHandler interface so that it can be handled or rethrown.

Eg:

struct Foo
{
Timer<Foo> m_timer ;
Foo( EventState es ) : m_timer(*this,&Foo::onTimeout,es) {}
void onTimeout() { throw "oops" ; }
} ;

Definition at line 140 of file gtimer.h.

Member Typedef Documentation

◆ method_type

template<typename T >
using GNet::Timer< T >::method_type = void (T::*)()

Definition at line 143 of file gtimer.h.

Constructor & Destructor Documentation

◆ Timer()

template<typename T >
GNet::Timer< T >::Timer ( T &  t,
method_type  m,
GNet::EventState  es 
)

Constructor.

Definition at line 178 of file gtimer.h.

Member Function Documentation

◆ active()

template<typename T >
bool GNet::Timer< T >::active
noexcept

Returns true if the timer is running.

Definition at line 210 of file gtimer.h.

◆ cancelTimer()

template<typename T >
void GNet::Timer< T >::cancelTimer

Cancels the timer. Does nothing if not running.

Definition at line 198 of file gtimer.h.

◆ startTimer() [1/2]

template<typename T >
void GNet::Timer< T >::startTimer ( const G::TimeInterval i)

Starts or restarts the timer so that it expires after the given interval.

Definition at line 192 of file gtimer.h.

◆ startTimer() [2/2]

template<typename T >
void GNet::Timer< T >::startTimer ( unsigned int  interval_s,
unsigned int  interval_us = 0U 
)

Starts or restarts the timer so that it expires after the given interval.

Definition at line 186 of file gtimer.h.


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