Returns the current time on the clock since the last call to restart, excluding times when the clock was paused.
Pauses the clock.
Restarts the clock from position zero.
Goes to sleep until the real clock catches up to the given position.
1000 = 1.0, 2000 = 2.0, 500 = 0.5, etc.
For example, suppose you want something to happen 60 frames per second:
MMClock clock; Duration frame; clock.restart(); while(running) { frame += 1.seconds / 60; bool onSchedule = clock.waitUntil(frame); do_essential_frame_work(); if(onSchedule) { // if we're on time, do other work too. // but if we weren't on time, skipping this // might help catch back up to where we're // supposed to be. do_would_be_nice_frame_work(); } }
A clock you can use for multimedia applications. It compares time elapsed against a position variable you pass in to figure out how long to wait to get to that point. Very similar to Phobos' StopWatch but with built-in wait capabilities.