From a5844adb7b6b564f77fb15ec0716ac85bcb1bc42 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Fri, 20 May 2022 20:01:04 +0100 Subject: cam: event_loop: Add timer events to event loop Extend the EventLoop class to support periodic timer events. This can be used to run tasks periodically, such as handling the event loop of SDL. Signed-off-by: Eric Curtin Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Tested-by: Jacopo Mondi Signed-off-by: Laurent Pinchart --- src/cam/event_loop.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/cam/event_loop.h') diff --git a/src/cam/event_loop.h b/src/cam/event_loop.h index 79902d87..ef79e8e5 100644 --- a/src/cam/event_loop.h +++ b/src/cam/event_loop.h @@ -7,9 +7,10 @@ #pragma once +#include #include -#include #include +#include #include #include @@ -37,6 +38,10 @@ public: void addFdEvent(int fd, EventType type, const std::function &handler); + using duration = std::chrono::steady_clock::duration; + void addTimerEvent(const std::chrono::microseconds period, + const std::function &handler); + private: struct Event { Event(const std::function &callback); -- cgit v1.2.1