|
smats
0.0.1
Satisfability Modulo Arithmetic Theories Symbols
|
#include <timer.h>
Public Member Functions | |
TimerGuard (Timer *timer, bool enabled, bool start_timer=true) | |
TimerGuard (const TimerGuard &)=delete | |
TimerGuard (TimerGuard &&)=delete | |
TimerGuard & | operator= (const TimerGuard &)=delete |
TimerGuard & | operator= (TimerGuard &&)=delete |
~TimerGuard () | |
void | pause () |
void | resume () |
Private Attributes | |
Timer *const | timer_ |
The timer to be guarded. | |
const bool | enabled_ {false} |
Whether the timer is enabled. | |
Wrap a timer object and pauses it when the guard object is destructed.
smats::TimerGuard::TimerGuard | ( | Timer * | timer, |
bool | enabled, | ||
bool | start_timer = true ) |
Construct a timer guard object.
If enabled
is false or timer
is a nullptr, this class does not do anything. If start_timer
is true, starts the timer
in the constructor. Otherwise, it does not start it and a user has to call resume()
to start it.
timer | the timer to be guarded |
enabled | whether the timer is enabled and will run |
start_timer | whether the timer should be started as soon as the guard is created |
smats::TimerGuard::~TimerGuard | ( | ) |
When the timer guard object is destructed, it pauses the embedded timer object. If the timer is not enabled, this function does nothing.
void smats::TimerGuard::pause | ( | ) |
Pause the guarded timer object
void smats::TimerGuard::resume | ( | ) |
Resume the guarded timer object