CoinTimer

This class implements a timer that also implements a tracing functionality.

This class implements a timer that also implements a tracing functionality.

Description

The timer stores the start time of the timer, for how much time it was set to and when does it expire (start + limit = end). Queries can be made that tell whether the timer is expired, is past an absolute time, is past a percentage of the length of the timer. All times are given in seconds, but as double numbers, so there can be fractional values. The timer can also be initialized with a stream and a specification whether to write to or read from the stream. In the former case the result of every query is written into the stream, in the latter case timing is not tested at all, rather the supposed result is read out from the stream. This makes it possible to exactly retrace time sensitive program execution.

Public Methods

CoinTimer

Default constructor creates a timer with no time limit and no tracing.

 CoinTimer()

CoinTimer

Create a timer with the given time limit and with no tracing.

 CoinTimer(double lim)

Parameters:

restart

Restart the timer (keeping the same time limit)

void restart()

reset

An alternate name for ``

void reset()

reset

Reset (and restart) the timer and change its time limit.

void reset(double lim)

Parameters:

isPastPercent

Return whether the given percentage of the time limit has elapsed since the timer was started.

bool isPastPercent(double pct)

Parameters:

isPast

Return whether the given amount of time has elapsed since the timer was started.

bool isPast(double lim)

Parameters:

isExpired

Return whether the originally specified time limit has passed since the timer was started.

bool isExpired()

timeLeft

Return how much time is left on the timer.

double timeLeft()

timeElapsed

Return how much time has elapsed.

double timeElapsed()

setLimit

void setLimit(double l)

Parameters:

Source

Header: layer-0/CoinUtils/src/CoinTime.hpp