From 4ac8765123a2eeb3fcf26b5914e7d3f87ae272e5 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Wed, 24 Jan 2024 09:03:30 +0100 Subject: [PATCH] User callback gets const timer& arg instead of ptr --- src/timer.cpp | 4 ++-- src/timer.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index 5cbca57..1ca03b0 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -9,12 +9,12 @@ std::mutex sc::timer::mutex; void sc::timer::callback(union sigval sv) { timer* self = reinterpret_cast(sv.sival_ptr); - self->_expired_func(self); + self->_expired_func(*self); } sc::timer::timer(double time, bool repeat, - void(*expired_func)(timer*), + void(*expired_func)(const timer&), void* context) : _id {}, _time {time}, _repeat {repeat}, _expired_func {expired_func}, _context {context} diff --git a/src/timer.hpp b/src/timer.hpp index 8f96da5..3eed608 100644 --- a/src/timer.hpp +++ b/src/timer.hpp @@ -14,7 +14,7 @@ namespace sc { uint64_t _id {}; double _time {}; bool _repeat {}; - void (*_expired_func)(timer* self); + void (*_expired_func)(const timer& self); void* _context {}; static void callback(union sigval); @@ -22,7 +22,7 @@ namespace sc { public: timer(double time, bool repeat, - void(*expired_func)(timer*), + void(*expired_func)(const timer&), void* context = nullptr); ~timer();