From f49e93338b6309a66b558dea40d114925f01e993 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 8 Nov 2020 01:26:33 +0200 Subject: cam: event_loop: Add deferred calls support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a deferred cals queue to the EventLoop class to support queuing calls from a different thread and processing them in the event loop's thread. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/cam/event_loop.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/cam/event_loop.h') diff --git a/src/cam/event_loop.h b/src/cam/event_loop.h index b1c6bd10..408073c5 100644 --- a/src/cam/event_loop.h +++ b/src/cam/event_loop.h @@ -8,6 +8,9 @@ #define __CAM_EVENT_LOOP_H__ #include +#include +#include +#include struct event_base; @@ -22,6 +25,8 @@ public: int exec(); void exit(int code = 0); + void callLater(const std::function &func); + private: static EventLoop *instance_; @@ -29,7 +34,11 @@ private: std::atomic exit_; int exitCode_; + std::list> calls_; + std::mutex lock_; + void interrupt(); + void dispatchCalls(); }; #endif /* __CAM_EVENT_LOOP_H__ */ -- cgit v1.2.1