diff options
author | Eric Curtin <ecurtin@redhat.com> | 2022-05-20 20:01:04 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-05-23 12:49:41 +0300 |
commit | a5844adb7b6b564f77fb15ec0716ac85bcb1bc42 (patch) | |
tree | 32e454ee7f199d67d4bdaf967f4411c597b422a1 /src/cam/event_loop.h | |
parent | 48e991476d73da73d8ef145074eb1ffd4cad6c16 (diff) |
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 <ecurtin@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/cam/event_loop.h')
-rw-r--r-- | src/cam/event_loop.h | 7 |
1 files changed, 6 insertions, 1 deletions
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 <chrono> #include <functional> -#include <memory> #include <list> +#include <memory> #include <mutex> #include <event2/util.h> @@ -37,6 +38,10 @@ public: void addFdEvent(int fd, EventType type, const std::function<void()> &handler); + using duration = std::chrono::steady_clock::duration; + void addTimerEvent(const std::chrono::microseconds period, + const std::function<void()> &handler); + private: struct Event { Event(const std::function<void()> &callback); |