E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected 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 >:

## Public Types
typedef void(T::* | method_type) ()

## Public Member Functions
| Timer (T &t, method_type m, ExceptionHandler &)
| Constructor. More...
Public Member Functions inherited from GNet::TimerBase
virtual | ~TimerBase ()
| Destructor.
void | startTimer (unsigned int interval_s, unsigned int interval_us=0U)
| Starts the timer so that it goes off after the given time interval. More...
void | startTimer (const G::EpochTime &interval_time)
| Overload for an interval expressed as an G::EpochTime.
void | cancelTimer ()
| Cancels the timer.
bool | active () const
| Returns true if the timer is started and not cancelled.
bool | immediate () const
| Used by TimerList. More...
void | doTimeout ()
| Used by TimerList to execute the onTimeout() callback.
G::EpochTime | t () const
| Used by TimerList to get the expiry epoch time.
bool | expired (G::EpochTime &) const
| Used by TimerList. More...

## Protected Member Functions
virtual void | onTimeout () override
| Override from GNet::TimerBase.
Protected Member Functions inherited from GNet::TimerBase
| TimerBase (ExceptionHandler &)
| Constructor.

## 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 EventHandler interface so that it can be handled or rethrown.

Eg:

struct Foo : public ExceptionHandler
{
Timer<Foo> m_timer ;
Foo() : m_timer(*this,&Foo::onTimeout,*this) {}
void onTimeout() {}
void onException( std::exception & ) { throw ; }
} ;

Definition at line 115 of file gtimer.h.

## Constructor & Destructor Documentation

template<typename T>

GNet::Timer< T >::Timer | ( | T & | t,
|  | method_type | m,
|  | ExceptionHandler & | e
| ) |  |

Constructor.

The ExceptionHandler reference is used when the timeout handler throws; the onException() implementation can simply rethrow to exit the event loop.

Definition at line 140 of file gtimer.h.

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

- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/gtimer.h