Skip to content
Snippets Groups Projects
Commit a77c1282 authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

osv/clock.hh: Add std::chrono::duration literals


In <drivers/clock.hh> we had support for time literals looking like 100_ns,
100_us, 100_ms, 100_s. These simply translated to an integer number of
nanoseconds.

Added to <osv/clock.hh> similar literals, but using strongly-typed
std::chrono::duration, so that 100_ms translates to
std::chrono::milliseconds(100), and this is, as usual, automatically
scaled by the compiler to other units when other units (e.g., nanoseconds)
are required.

Because the literals of <drivers/clock.hh> and <osv/clock.hh> have the
same name, to use the latter you need to explicitly enable them in a scope
using the statement

    using namespace osv::clock::literals;

One the entire codebase is converted to use <osv/clock.hh> and std::chrono,
the old literals from <drivers/clock.hh> should be removed.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent f6d28b1b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment