User callback changed, better interface

This commit is contained in:
2024-01-23 20:43:39 +01:00
parent d9233605f9
commit df1e984c5a
2 changed files with 28 additions and 10 deletions

View File

@ -11,19 +11,28 @@ namespace sc {
static std::mutex mutex;
timer_t _tid;
uint64_t _id;
double _time;
bool _repeat;
uint64_t _id {};
double _time {};
bool _repeat {};
void (*_expired_func)(timer* self, void* context);
void* _context {};
static void callback(union sigval);
public:
timer(void(*callback)(union sigval), double time, bool repeat = false);
timer(void(*expired_func)(timer*, void*),
double time,
bool repeat,
void* context);
~timer();
uint64_t id() const { return _id; }
double time() const { return _time; }
bool repeat() const { return _repeat; }
bool is_armed() const;
void time_left(struct itimerspec& cur_value) const;
double time_left() const;
double time() const { return _time; }
bool is_armed() const;
bool repeat() const { return _repeat; }
};
}