diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-11-08 01:26:33 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-11-15 22:21:30 +0200 |
commit | f49e93338b6309a66b558dea40d114925f01e993 (patch) | |
tree | a60dfc235805559cb53fcc27115ebe7ee18955a6 /src/cam/event_loop.h | |
parent | d767c84022559e55708f24a3a264853c0142135e (diff) |
cam: event_loop: Add deferred calls support
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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/cam/event_loop.h')
-rw-r--r-- | src/cam/event_loop.h | 9 |
1 files changed, 9 insertions, 0 deletions
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 <atomic> +#include <functional> +#include <list> +#include <mutex> struct event_base; @@ -22,6 +25,8 @@ public: int exec(); void exit(int code = 0); + void callLater(const std::function<void()> &func); + private: static EventLoop *instance_; @@ -29,7 +34,11 @@ private: std::atomic<bool> exit_; int exitCode_; + std::list<std::function<void()>> calls_; + std::mutex lock_; + void interrupt(); + void dispatchCalls(); }; #endif /* __CAM_EVENT_LOOP_H__ */ |