User callback gets const timer& arg instead of ptr

This commit is contained in:
Bob Polis 2024-01-24 09:03:30 +01:00
parent dbbbbd92bb
commit 4ac8765123
2 changed files with 4 additions and 4 deletions

View File

@ -9,12 +9,12 @@ std::mutex sc::timer::mutex;
void sc::timer::callback(union sigval sv) { void sc::timer::callback(union sigval sv) {
timer* self = reinterpret_cast<timer*>(sv.sival_ptr); timer* self = reinterpret_cast<timer*>(sv.sival_ptr);
self->_expired_func(self); self->_expired_func(*self);
} }
sc::timer::timer(double time, sc::timer::timer(double time,
bool repeat, bool repeat,
void(*expired_func)(timer*), void(*expired_func)(const timer&),
void* context) void* context)
: _id {}, _time {time}, _repeat {repeat}, : _id {}, _time {time}, _repeat {repeat},
_expired_func {expired_func}, _context {context} _expired_func {expired_func}, _context {context}

View File

@ -14,7 +14,7 @@ namespace sc {
uint64_t _id {}; uint64_t _id {};
double _time {}; double _time {};
bool _repeat {}; bool _repeat {};
void (*_expired_func)(timer* self); void (*_expired_func)(const timer& self);
void* _context {}; void* _context {};
static void callback(union sigval); static void callback(union sigval);
@ -22,7 +22,7 @@ namespace sc {
public: public:
timer(double time, timer(double time,
bool repeat, bool repeat,
void(*expired_func)(timer*), void(*expired_func)(const timer&),
void* context = nullptr); void* context = nullptr);
~timer(); ~timer();