From f2a848cbcc41f29fb62ee67aef95136ae1a650da Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 7 Apr 2024 03:31:51 +0100 Subject: core: Event loop rework (#5466) * Event loop rework * revert missed --- src/managers/eventLoop/EventLoopTimer.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/managers/eventLoop/EventLoopTimer.hpp (limited to 'src/managers/eventLoop/EventLoopTimer.hpp') diff --git a/src/managers/eventLoop/EventLoopTimer.hpp b/src/managers/eventLoop/EventLoopTimer.hpp new file mode 100644 index 00000000..8865d29f --- /dev/null +++ b/src/managers/eventLoop/EventLoopTimer.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include + +class CEventLoopTimer { + public: + CEventLoopTimer(std::optional timeout, std::function self, void* data)> cb_, void* data_); + + // if not specified, disarms. + // if specified, arms. + void updateTimeout(std::optional timeout); + + void cancel(); + bool passed(); + + float leftUs(); + + bool cancelled(); + // resets expires + void call(std::shared_ptr self); + + private: + std::function self, void* data)> cb; + void* data = nullptr; + std::optional expires; + bool wasCancelled = false; +}; -- cgit v1.2.3