17#include <units/frequency.h>
18#include <units/time.h>
39 explicit Notifier(std::function<
void()> callback);
41 template <
typename Arg,
typename... Args>
42 Notifier(std::invocable<Arg, Args...>
auto&& callback, Arg&&
arg,
46 std::forward<Args>(args)...)) {}
62 explicit Notifier(
int priority, std::function<
void()> callback);
64 template <
typename Arg,
typename... Args>
65 Notifier(
int priority, std::invocable<Arg, Args...>
auto&& callback,
66 Arg&&
arg, Args&&... args)
67 :
Notifier(priority,
std::bind(
std::forward<decltype(callback)>(callback),
69 std::forward<Args>(args)...)) {}
156 void UpdateAlarm(uint64_t triggerTime);
164 std::thread m_thread;
170 std::atomic<HAL_NotifierHandle> m_notifier{0};
173 std::function<void()> m_callback;
177 units::second_t m_expirationTime = 0_s;
181 units::second_t m_period = 0_s;
184 bool m_periodic =
false;
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Returns a named argument to be used in a formatting function.
Definition base.h:2775
Notifiers run a user-provided callback function on a separate thread.
Definition Notifier.h:30
Notifier(std::invocable< Arg, Args... > auto &&callback, Arg &&arg, Args &&... args)
Definition Notifier.h:42
Notifier(std::function< void()> callback)
Create a Notifier with the given callback.
void StartPeriodic(units::hertz_t frequency)
Run the callback periodically with the given frequency.
void StartPeriodic(units::second_t period)
Run the callback periodically with the given period.
void SetName(std::string_view name)
Sets the name of the notifier.
void Stop()
Stop further callback invocations.
Notifier(int priority, std::function< void()> callback)
Create a Notifier with the given callback.
static bool SetHALThreadPriority(bool realTime, int32_t priority)
Sets the HAL notifier thread priority.
void StartSingle(units::second_t delay)
Run the callback once after the given delay.
void SetCallback(std::function< void()> callback)
Change the callback function.
Notifier(int priority, std::invocable< Arg, Args... > auto &&callback, Arg &&arg, Args &&... args)
Definition Notifier.h:65
~Notifier()
Free the resources for a timer event.
Notifier & operator=(Notifier &&rhs)
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
::std::mutex mutex
Definition mutex.h:17