From 71ef5532d9777e9511bc982cab33e3d2d95cf4be Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Jan 2019 10:17:21 +0200 Subject: cam: Add event loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a simple event loop to the cam application and use it in the main() function, with an example of how to handle SIGINT to gracefully stop the loop. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/cam/event_loop.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/cam/event_loop.h (limited to 'src/cam/event_loop.h') diff --git a/src/cam/event_loop.h b/src/cam/event_loop.h new file mode 100644 index 00000000..aaca5838 --- /dev/null +++ b/src/cam/event_loop.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * event_loop.h - cam - Event loop + */ +#ifndef __CAM_EVENT_LOOP_H__ +#define __CAM_EVENT_LOOP_H__ + +#include + +#include + +namespace libcamera { +class EventDispatcher; +}; + +class EventLoop +{ +public: + EventLoop(libcamera::EventDispatcher *dispatcher); + ~EventLoop(); + + int exec(); + void exit(int code = 0); + +private: + libcamera::EventDispatcher *dispatcher_; + + std::atomic exit_; + int exitCode_; +}; + +#endif /* __CAM_EVENT_LOOP_H__ */ -- cgit v1.2.1