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

clock: add clock_event::set(timepoint)


In the previous patch we built clock_event::set(s64) on top of
set(duration). In this patch we add set(timepoint), for absolute time
in any clock supporting the now() static method. In the following patches,
we'll convert our timers to using the monotonic clock osv::clock::uptime,
and use timepoints of that clock in calls to clock_event::set().

By temporarily having both s64 and std::chrono:time_point versions
of set(), we make this patch series bisectable. At the end of this series,
the s64 variant will be removed.

Reviewed-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 5c5f5971
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,14 @@ public:
s64 now = clock::get()->time();
set(std::chrono::nanoseconds(time - now));
}
// Can be used on a std::chrono::time_point of a clock which supports
// the now() method. For example osv::clock::uptime::time_point.
template<class timepoint>
inline void set(timepoint time) {
auto now = timepoint::clock::now();
using namespace std::chrono;
set(duration_cast<nanoseconds>(time - now));
}
void set_callback(clock_event_callback* callback);
clock_event_callback* callback() const;
protected:
......
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