FreeNOS
Public Types | Public Member Functions | Private Attributes
SystemClock Class Reference

Provides an abstract interface to the system clock. More...

#include <SystemClock.h>

Public Types

enum  Result { Success, IOError }
 Result codes. More...
 

Public Member Functions

 SystemClock ()
 Constructor. More...
 
void value (struct timeval &val) const
 Get time value. More...
 
Result now ()
 Get the current time. More...
 
void printDiff (const SystemClock &clock) const
 Print difference between two clocks to stdout. More...
 
void printDiff (const struct timeval &stamp) const
 Print difference between to timestamps to stdout. More...
 

Private Attributes

struct timeval m_timeval
 Time value. More...
 

Detailed Description

Provides an abstract interface to the system clock.

Definition at line 34 of file SystemClock.h.

Member Enumeration Documentation

◆ Result

Result codes.

Enumerator
Success 
IOError 

Definition at line 41 of file SystemClock.h.

Constructor & Destructor Documentation

◆ SystemClock()

SystemClock::SystemClock ( )

Constructor.

Definition at line 23 of file SystemClock.cpp.

References m_timeval, timeval::tv_sec, and timeval::tv_usec.

Member Function Documentation

◆ now()

SystemClock::Result SystemClock::now ( )

Get the current time.

Returns
Result code

Definition at line 35 of file SystemClock.cpp.

References gettimeofday(), IOError, m_timeval, and Success.

Referenced by MpiPrime::exec(), TimeCommand::execute(), and MpiPrime::searchParallel().

◆ printDiff() [1/2]

void SystemClock::printDiff ( const struct timeval stamp) const

Print difference between to timestamps to stdout.

Parameters
stampTimestamp to compare with

Definition at line 54 of file SystemClock.cpp.

References m_timeval, printf(), timeval::tv_sec, and timeval::tv_usec.

◆ printDiff() [2/2]

void SystemClock::printDiff ( const SystemClock clock) const

Print difference between two clocks to stdout.

Parameters
clockClock to compare with

Definition at line 49 of file SystemClock.cpp.

References m_timeval.

Referenced by MpiPrime::exec(), TimeCommand::execute(), and MpiPrime::searchParallel().

◆ value()

void SystemClock::value ( struct timeval val) const

Get time value.

Parameters
valTimeval struct

Definition at line 29 of file SystemClock.cpp.

References m_timeval, timeval::tv_sec, and timeval::tv_usec.

Field Documentation

◆ m_timeval

struct timeval SystemClock::m_timeval
private

Time value.

Definition at line 85 of file SystemClock.h.

Referenced by now(), printDiff(), SystemClock(), and value().


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