class::chrono::MicroTime

class chrono::MicroTime
  : public api::ChronoInfoObject

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 MicroTime & micro_time); //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

Members

explicit MicroTime(

u32 microseconds
)

MicroTime(

const ClockTime & clock_time
)

MicroTime(

const Seconds & seconds
)

MicroTime(

const Milliseconds & milliseconds
)

MicroTime(

const Microseconds & microseconds
)

MicroTime(

const Nanoseconds & nanoseconds
)

MicroTime(

const Timer & timer
)

bool is_valid() const
micro_time_t microseconds() const
u32 milliseconds() const
bool operator !=(

const MicroTime & a
) const

MicroTime & operator -=(

const MicroTime & micro_time
)

bool operator >(

const MicroTime & a
) const

bool operator >=(

const MicroTime & a
) const

MicroTime operator+(

const MicroTime & micro_time
)

MicroTime & operator+=(

const MicroTime & micro_time
)

bool operator<(

const MicroTime & a
) const

MicroTime & operator<<(

const Seconds & a
)

MicroTime & operator<<(

const Milliseconds & a
)

MicroTime & operator<<(

const Microseconds & a
)

MicroTime & operator<<(

const Nanoseconds & a
)

bool operator<=(

const MicroTime & a
)

bool operator==(

const MicroTime & a
) const

u32 seconds() const
void set_microseconds(

micro_time_t microseconds
)

void set_milliseconds(

u32 milliseconds
)

void set_seconds(

u32 seconds
)

void wait() const
static MicroTime from_microseconds(

u32 microseconds
)

static MicroTime from_milliseconds(

u32 msec
)

static MicroTime from_seconds(

u32 sec
)

static MicroTime invalid()

Details

explicit MicroTime(

u32 microseconds
)

Constructs a MicroTime object using a u32 microsecond value.

The default initial value is zero.


MicroTime(

const ClockTime & clock_time
)

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


MicroTime(

const Seconds & seconds
)


MicroTime(

const Milliseconds & milliseconds
)


MicroTime(

const Microseconds & microseconds
)


MicroTime(

const Nanoseconds & nanoseconds
)


MicroTime(

const Timer & timer
)

Constructs a MicroTime 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 MicroTime & a
) const

Compares inequality to another MicroTime object.


MicroTime & operator -=(

const MicroTime & micro_time
)

Assignment addition to another MicroTime object.


bool operator >(

const MicroTime & a
) const

Compares > to another MicroTime object.


bool operator >=(

const MicroTime & a
) const

Compares >= to another MicroTime object.


MicroTime operator+(

const MicroTime & micro_time
)


MicroTime & operator+=(

const MicroTime & micro_time
)

Assignment addition to another MicroTime object.


bool operator<(

const MicroTime & a
) const

Compares < to another MicroTime object.


MicroTime & operator<<(

const Seconds & a
)


MicroTime & operator<<(

const Milliseconds & a
)


MicroTime & operator<<(

const Microseconds & a
)


MicroTime & operator<<(

const Nanoseconds & a
)


bool operator<=(

const MicroTime & a
)

Compares <= to another MicroTime object.


bool operator==(

const MicroTime & a
) const

Compares equality to another MicroTime object.


u32 seconds() const

Returns the value in seconds.


void set_microseconds(

micro_time_t microseconds
)

Sets the value of the time in microseconds.


void set_milliseconds(

u32 milliseconds
)

Sets the value of the time in milliseconds.


void set_seconds(

u32 seconds
)

Sets the value of the time in seconds.


void wait() const

Waits for the value of the microtime.


static MicroTime from_microseconds(

u32 microseconds
)

Create a MicroTime object from a microsecond value.

The following objects will be initialized with the same value because the constructor value assumes microseconds.

MicroTime time_from_microseconds(MicroTime::from_microseconds(1000));
MicroTime time_microseconds(1000);

static MicroTime from_milliseconds(

u32 msec
)

Create a MicroTime object from a millisecond value.


static MicroTime from_seconds(

u32 sec
)

Create a MicroTime object from a second value.


static MicroTime invalid()

Returns a MicroTime object set to the invalid time value.


X

Thanks for Coming!

Subscribe to news and updates