-
Nadav Har'El authored
For this patch series to be bisectable, the previous patches left behind some features, or temporarily added features, that we couldn't remove until they are no longer use. Now we can finally delete these unused features: 1. After the previous patches stopped using clock::get()->time() in sched.cc, we can drop the alias osv::clock::get() we added temporarily just to make it easier to compile the first patches in this series. 2. Drop the clock_event::set(s64) variant. 3. Drop the timer_base::set(s64) variant. Fixes #81. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
Nadav Har'El authoredFor this patch series to be bisectable, the previous patches left behind some features, or temporarily added features, that we couldn't remove until they are no longer use. Now we can finally delete these unused features: 1. After the previous patches stopped using clock::get()->time() in sched.cc, we can drop the alias osv::clock::get() we added temporarily just to make it easier to compile the first patches in this series. 2. Drop the clock_event::set(s64) variant. 3. Drop the timer_base::set(s64) variant. Fixes #81. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
clockevent.hh 1.24 KiB
/*
* 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_
#include <osv/types.h>
#include <chrono>
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();
virtual void setup_on_cpu() = 0;
// 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));
}
void set_callback(clock_event_callback* callback);
clock_event_callback* callback() const;
protected:
clock_event_callback* _callback;
};
extern clock_event_driver* clock_event;
#endif /* CLOCKEVENT_HH_ */