From 2aa529ebf174a3a9e6fe720978595d8bb2a5d206 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Wed, 31 Jan 2024 14:39:46 +0100 Subject: [PATCH] Forbid copying, moving; Add overrun getter --- src/timer.cpp | 5 +++++ src/timer.hpp | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/timer.cpp b/src/timer.cpp index 424160f..a0532a1 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "timer.hpp" @@ -90,3 +91,7 @@ void sc::timer::start(double time, bool repeat) { setup_timer(time, repeat); } } + +int sc::timer::overrun() const { + return timer_getoverrun(_tid); +} diff --git a/src/timer.hpp b/src/timer.hpp index e034f52..7c9b4ae 100644 --- a/src/timer.hpp +++ b/src/timer.hpp @@ -26,6 +26,14 @@ namespace sc { void* context = nullptr); ~timer(); + // forbid copying + timer(const timer&) = delete; + timer& operator=(const timer&) = delete; + + // forbid moveing + timer(timer&&) = delete; + timer& operator=(timer&&) = delete; + uint64_t id() const { return _id; } double time() const { return _time; } bool repeat() const { return _repeat; } @@ -34,6 +42,7 @@ namespace sc { bool is_armed() const; void time_left(struct itimerspec& cur_value) const; double time_left() const; + int overrun() const; void stop(); void start();