#pragma once #include "ports/event_publisher.h" #include "schedule/reminder_schedule.h" #include "schedule/schedule_types.h" #include #include #include #include #include #include namespace borla { class ReminderService final { public: bool Initialize(IEventPublisher& publisher); void Stop(); bool Add(uint32_t duration_seconds); void Cancel(TimerCancelScope scope); size_t count() const; uint64_t NextWakeupDelayUs() const; private: static constexpr uint32_t kTaskStackDepth = 2048; static void TaskEntry(void* context); void Run(); static uint64_t NowMs(); IEventPublisher* publisher_ = nullptr; mutable SemaphoreHandle_t mutex_ = nullptr; mutable StaticSemaphore_t mutex_control_{}; ReminderSchedule schedule_; std::atomic running_{false}; TaskHandle_t task_ = nullptr; StaticTask_t task_control_{}; std::array task_stack_{}; }; } // namespace borla