PIVX Core  5.6.99
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
cxxtimer::Timer Class Reference

This class works as a stopwatch. More...

#include <cxxtimer.h>

Public Member Functions

 Timer (bool start=false)
 Constructor. More...
 
 Timer (const Timer &other)=default
 Copy constructor. More...
 
 Timer (Timer &&other)=default
 Transfer constructor. More...
 
virtual ~Timer ()=default
 Destructor. More...
 
Timeroperator= (const Timer &other)=default
 Assignment operator by copy. More...
 
Timeroperator= (Timer &&other)=default
 Assignment operator by transfer. More...
 
void start ()
 Start/resume the timer. More...
 
void stop ()
 Stop/pause the timer. More...
 
void reset ()
 Reset the timer. More...
 
template<class duration_t = std::chrono::milliseconds>
duration_t::rep count () const
 Return the elapsed time. More...
 

Private Attributes

bool started_
 
bool paused_
 
std::chrono::steady_clock::time_point reference_
 
std::chrono::duration< long double > accumulated_
 

Detailed Description

This class works as a stopwatch.

Definition at line 37 of file cxxtimer.h.

Constructor & Destructor Documentation

◆ Timer() [1/3]

cxxtimer::Timer::Timer ( bool  start = false)
inlineexplicit

Constructor.

Parameters
startIf true, the timer is started just after construction. Otherwise, it will not be automatically started.

Definition at line 130 of file cxxtimer.h.

Here is the call graph for this function:

◆ Timer() [2/3]

cxxtimer::Timer::Timer ( const Timer other)
default

Copy constructor.

Parameters
otherThe object to be copied.

◆ Timer() [3/3]

cxxtimer::Timer::Timer ( Timer &&  other)
default

Transfer constructor.

Parameters
otherThe object to be transferred.

◆ ~Timer()

virtual cxxtimer::Timer::~Timer ( )
virtualdefault

Destructor.

Member Function Documentation

◆ count()

template<class duration_t >
duration_t::rep cxxtimer::Timer::count

Return the elapsed time.

Parameters
duration_tThe duration type used to return the time elapsed. If not specified, it returns the time as represented by std::chrono::milliseconds.
Returns
The elapsed time.

Definition at line 169 of file cxxtimer.h.

Here is the caller graph for this function:

◆ operator=() [1/2]

Timer& cxxtimer::Timer::operator= ( const Timer other)
default

Assignment operator by copy.

Parameters
otherThe object to be copied.
Returns
A reference to this object.

◆ operator=() [2/2]

Timer& cxxtimer::Timer::operator= ( Timer &&  other)
default

Assignment operator by transfer.

Parameters
otherThe object to be transferred.
Returns
A reference to this object.

◆ reset()

void cxxtimer::Timer::reset ( )
inline

Reset the timer.

Definition at line 159 of file cxxtimer.h.

◆ start()

void cxxtimer::Timer::start ( )
inline

Start/resume the timer.

Definition at line 139 of file cxxtimer.h.

Here is the caller graph for this function:

◆ stop()

void cxxtimer::Timer::stop ( )
inline

Stop/pause the timer.

Definition at line 151 of file cxxtimer.h.

Here is the caller graph for this function:

Member Data Documentation

◆ accumulated_

std::chrono::duration<long double> cxxtimer::Timer::accumulated_
private

Definition at line 124 of file cxxtimer.h.

◆ paused_

bool cxxtimer::Timer::paused_
private

Definition at line 122 of file cxxtimer.h.

◆ reference_

std::chrono::steady_clock::time_point cxxtimer::Timer::reference_
private

Definition at line 123 of file cxxtimer.h.

◆ started_

bool cxxtimer::Timer::started_
private

Definition at line 121 of file cxxtimer.h.


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