VideoTools
|
A timer class template in which the timeout is delivered to the specified method. More...
#include <gtimer.h>
Public Types | |
typedef void(T::* | method_type )() |
Public Member Functions | |
Timer (T &t, method_type m, EventExceptionHandler &event_exception_handler) | |
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 |
Returns true if the timer is active() and zero-length. | |
Protected Member Functions | |
virtual void | onTimeout () override |
Override from GNet::TimerBase. | |
virtual void | onException (std::exception &) override |
Override from GNet::EventExceptionHandler. | |
Protected Member Functions inherited from GNet::TimerBase | |
TimerBase () | |
Default constructor. | |
Protected Member Functions inherited from GNet::EventExceptionHandler | |
virtual | ~EventExceptionHandler () |
Destructor. | |
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:
GNet::Timer< T >::Timer | ( | T & | t, |
method_type | m, | ||
EventExceptionHandler & | event_exception_handler | ||
) |
Constructor.
The EventExceptionHandler reference is required in case the timeout handler throws; the onException() implementation can simply rethrow to exit the event loop.