Newer
Older
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
#ifndef CLOCKEVENT_HH_
#define CLOCKEVENT_HH_
class clock_event_callback {
public:
virtual ~clock_event_callback();
// note: must always be called on the same cpu that the timer was set on
virtual void fired() = 0;
};
class clock_event_driver {
public:
virtual ~clock_event_driver();
// set() is cpu-local: each processor has its own timer
virtual void set(std::chrono::nanoseconds time) = 0;
// 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));
}