From 6831eaa7c33cd2a7a0d5c12535d8b6138e967298 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 23 Jan 2024 16:39:41 +0100 Subject: [PATCH] Cleanup namespace usage --- src/timer.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index 9fcbf83..612a6be 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -1,16 +1,13 @@ -#include #include #include #include #include #include "timer.hpp" -using namespace sc; +uint64_t sc::timer::next_id = 0; +std::mutex sc::timer::mutex; -uint64_t timer::next_id = 0; -std::mutex timer::mutex; - -timer::timer(void(*callback)(union sigval), double time, bool repeat) +sc::timer::timer(void(*callback)(union sigval), double time, bool repeat) : _id {}, _time {time}, _repeat {repeat} { { @@ -39,21 +36,21 @@ timer::timer(void(*callback)(union sigval), double time, bool repeat) throw_if_min1_msg(timer_settime(_tid, 0, &its, nullptr), "could not set timer"); } -timer::~timer() { - throw_if_min1_msg(timer_delete(_tid), "could not delete timer"); +sc::timer::~timer() { + timer_delete(_tid); } -void timer::time(struct itimerspec& cur_value) const { +void sc::timer::time(struct itimerspec& cur_value) const { throw_if_min1_msg(timer_gettime(_tid, &cur_value), "could not get time"); } -double timer::time() const { +double sc::timer::time() const { struct itimerspec its; time(its); return its.it_value.tv_sec + its.it_value.tv_nsec * 1000000000; } -bool timer::is_armed() const { +bool sc::timer::is_armed() const { struct itimerspec its; time(its); return its.it_value.tv_sec != 0 || its.it_value.tv_nsec != 0;