class::chrono::Microseconds

class chrono::Microseconds
  : public api::InfoObject

The MicroTime class is used for keeping track of microsecond accurate time intervals. It uses a 32-bit value so it is good for 4 billion microseconds (or about 66 minutes).

It is very handy for converting between microseconds, milliseconds, and seconds. It also serves to remove ambiguity when specifying short time intervals.

For example:

void set_period(const Microseconds & microseconds); //un-ambiguous and nice code completion
void set_period(u32 value); //the units here are not clear
void set_period_milliseconds(u32 value); //this is better but adds complexity
//md2code:include
#include <sapi/chrono.hpp>

Summary

explicit [Microseconds](#classchrono_1_1_microseconds_1a51f6e9b931777056ebe95366b50e9911)(  

u32 microseconds
)

Microseconds(

const ClockTime & clock_time
)

[Microseconds](#classchrono_1_1_microseconds_1a2dee544b101fd4dca48e23a537da6083)(  

const Seconds & seconds
)

[Microseconds](#classchrono_1_1_microseconds_1a89bc424903cf57b7abd4bda1792468d7)(  

const Milliseconds & milliseconds
)

[Microseconds](#classchrono_1_1_microseconds_1ab9f21eca2ee34eee8be191a4e10a3c4d)(  

const Nanoseconds & nanoseconds
)

Microseconds(

const Timer & timer
)

bool is_valid() const

micro_time_t microseconds() const

u32 milliseconds() const

bool operator !=(

const Microseconds & a
) const

Microseconds operator -(

const Microseconds & a
) const

Microseconds & operator -=(

const Microseconds & a
)

bool operator >(

const Microseconds & a
) const

bool operator >=(

const Microseconds & a
) const

Microseconds operator+(

const Microseconds & a
) const

Microseconds & operator+=(

const Microseconds & a
)

bool operator<(

const Microseconds & a
) const

Microseconds & operator<<(

const Seconds & a
)

Microseconds & operator<<(

const Milliseconds & a
)

Microseconds & operator<<(

const Microseconds & a
)

Microseconds & operator<<(

const Nanoseconds & a
)

bool operator<=(

const Microseconds & a
)

bool operator==(

const Microseconds & a
) const

u32 seconds() const

void wait() const

static Microseconds invalid()

Members

explicit Microseconds(

u32 microseconds
)

Constructs a Microseconds object using a u32 microsecond value.

The default initial value is zero.

//md2code:main
//must be explicitly constructed
Microseconds duration = Microseconds(5);
printf("Duration is %ld microseconds\n", duration.microseconds());

Microseconds(

const ClockTime & clock_time
)

Constructs a Microseconds object from a chrono::ClockTime value.


Microseconds(

const Seconds & seconds
)

Constructs a Microseconds object from a chrono::Seconds value.

//md2code:main
Microseconds duration = Seconds(5); //converted to microseconds
printf("Duration is %ld microseconds\n", duration.microseconds());

Microseconds(

const Milliseconds & milliseconds
)

Constructs a Microseconds object from a chrono::Milliseconds value.

//md2code:main
Microseconds duration = Milliseconds(3000); //converted to microseconds
printf("Duration is %ld microseconds\n", duration.microseconds());

Microseconds(

const Nanoseconds & nanoseconds
)

Constructs a Microseconds object from a chrono::Nanoseconds value.

//md2code:main
Microseconds duration = Nanoseconds(3000); //converted to microseconds
Microseconds zero = Nanoseconds(999); //converted using truncation -- goes to zero
printf("Duration is %ld microseconds\n", duration.microseconds());
printf("Zero is %ld microseconds\n", zero.microseconds());

Microseconds(

const Timer & timer
)

Constructs a Microseconds object from the current value of a chrono::Timer.


bool is_valid() const

Returns true if the time is set to a valid value.


micro_time_t microseconds() const

Returns the value in microseconds.


u32 milliseconds() const

Returns the value in milliseconds.


bool operator !=(

const Microseconds & a
) const

Compares inequality to another MicroTime object.


Microseconds operator -(

const Microseconds & a
) const


Microseconds & operator -=(

const Microseconds & a
)

Assignment addition to another MicroTime object.


bool operator >(

const Microseconds & a
) const

Compares > to another MicroTime object.


bool operator >=(

const Microseconds & a
) const

Compares >= to another MicroTime object.


Microseconds operator+(

const Microseconds & a
) const


Microseconds & operator+=(

const Microseconds & a
)

Assignment addition to another MicroTime object.


bool operator<(

const Microseconds & a
) const

Compares < to another MicroTime object.


Microseconds & operator<<(

const Seconds & a
)


Microseconds & operator<<(

const Milliseconds & a
)


Microseconds & operator<<(

const Microseconds & a
)


Microseconds & operator<<(

const Nanoseconds & a
)


bool operator<=(

const Microseconds & a
)

Compares <= to another MicroTime object.


bool operator==(

const Microseconds & a
) const

Compares equality to another MicroTime object.


u32 seconds() const

Returns the value in seconds.


void wait() const

Waits for the value of the microtime.


static Microseconds invalid()

Returns a MicroTime object set to the invalid time value.


X

Thanks for Coming!

Subscribe to news and updates