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;