BipedalLocomotion::System::StdClock class final

StdClock implements the IClock interface using <chrono> from c++std library.

The clock can be easily used as follows

#include <BipedalLocomotion/System/Clock.h>


auto start = BipedalLocomotion::clock().now();
foo();
auto end = BipedalLocomotion::clock().now();
std::chrono::duration<double, std::milli> elapsed = end-start;

Base classes

class IClock
IClock is the interface to the clock.

Public functions

auto now() -> std::chrono::nanoseconds final
Get the system current time.
void sleepFor(const std::chrono::nanoseconds& sleepDuration) final
Blocks the execution of the current thread for at least the specified sleepDuration.
void sleepUntil(const std::chrono::nanoseconds& sleepTime) final
Blocks the execution of the current thread until specified sleepTime has been reached.
void yield() final
Provides a hint to the implementation to reschedule the execution of threads, allowing other threads to run.

Function documentation

std::chrono::nanoseconds BipedalLocomotion::System::StdClock::now() final

Get the system current time.

Returns the current time since epoch computed with std::chrono::system_clock

void BipedalLocomotion::System::StdClock::sleepFor(const std::chrono::nanoseconds& sleepDuration) final

Blocks the execution of the current thread for at least the specified sleepDuration.

void BipedalLocomotion::System::StdClock::sleepUntil(const std::chrono::nanoseconds& sleepTime) final

Blocks the execution of the current thread until specified sleepTime has been reached.