Cleanup namespace usage

This commit is contained in:
Bob Polis 2024-01-23 16:39:41 +01:00
parent b2e1b47d31
commit 6831eaa7c3

View File

@ -1,16 +1,13 @@
#include <bits/types/struct_itimerspec.h>
#include <cmath> #include <cmath>
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
#include <libscerror.hpp> #include <libscerror.hpp>
#include "timer.hpp" #include "timer.hpp"
using namespace sc; uint64_t sc::timer::next_id = 0;
std::mutex sc::timer::mutex;
uint64_t timer::next_id = 0; sc::timer::timer(void(*callback)(union sigval), double time, bool repeat)
std::mutex timer::mutex;
timer::timer(void(*callback)(union sigval), double time, bool repeat)
: _id {}, _time {time}, _repeat {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"); throw_if_min1_msg(timer_settime(_tid, 0, &its, nullptr), "could not set timer");
} }
timer::~timer() { sc::timer::~timer() {
throw_if_min1_msg(timer_delete(_tid), "could not delete 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"); 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; struct itimerspec its;
time(its); time(its);
return its.it_value.tv_sec + its.it_value.tv_nsec * 1000000000; 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; struct itimerspec its;
time(its); time(its);
return its.it_value.tv_sec != 0 || its.it_value.tv_nsec != 0; return its.it_value.tv_sec != 0 || its.it_value.tv_nsec != 0;