The chrono namespace includes the following time-measurement objects.
- Microseconds: 32-bit value for microseconds
- ClockTime: 64-bit value for seconds and nanoseconds (clock as in CPU clock)
- Time: 32-bit value in seconds (basically a time_t object)
//md2code:include #include <sapi/chrono.hpp>
//md2code:main wait(Seconds(1)); //wait for one second wait(Milliseconds(1000)); //wait for one second wait(Microseconds(1000000)); //wait for one second ClockTime clock_time; wait(clock_time); //wait based on a clock time value Microseconds microseconds; microseconds = Milliseconds(100); wait(microseconds); //wait based on a microsecond value
- class chrono::Clock
- class chrono::ClockTime
- class chrono::Hours
- class chrono::Microseconds
- class chrono::Milliseconds
- class chrono::Minutes
- class chrono::Nanoseconds
- class chrono::Seconds
- class chrono::Time
- class chrono::Timer
const chrono::Microseconds & microseconds
Delays based on a chrono::Microseconds value.
//md2code:main wait(Microseconds(100)); //Milliseconds, Seconds, and Nanoseconds will convert to Microseconds automatically wait(Seconds(3)); wait(Milliseconds(3000)); wait(Nanoseconds(60000)); wait(Nanoseconds(999)); //this won't wait because it converts to 0 microseconds
This method will yield control of the processor to another thread. So the delay time may go over based on scheduling constraints.
typedef u32 micro_time_t
Defines the type for a chrono::MicroTime value.