From d767c84022559e55708f24a3a264853c0142135e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 8 Nov 2020 01:14:38 +0200 Subject: libcamera: Move EventDispatcher to internal API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no user of the EventDispatcher (and the related EventNotifier and Timer classes) outside of libcamera. Move those classes to the internal API. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- include/libcamera/internal/timer.h | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 include/libcamera/internal/timer.h (limited to 'include/libcamera/internal/timer.h') diff --git a/include/libcamera/internal/timer.h b/include/libcamera/internal/timer.h new file mode 100644 index 00000000..f55fe3c0 --- /dev/null +++ b/include/libcamera/internal/timer.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * timer.h - Generic timer + */ +#ifndef __LIBCAMERA_TIMER_H__ +#define __LIBCAMERA_TIMER_H__ + +#include +#include + +#include +#include + +namespace libcamera { + +class Message; + +class Timer : public Object +{ +public: + Timer(Object *parent = nullptr); + ~Timer(); + + void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); } + void start(std::chrono::milliseconds duration); + void start(std::chrono::steady_clock::time_point deadline); + void stop(); + bool isRunning() const; + + std::chrono::steady_clock::time_point deadline() const { return deadline_; } + + Signal timeout; + +protected: + void message(Message *msg) override; + +private: + void registerTimer(); + void unregisterTimer(); + + bool running_; + std::chrono::steady_clock::time_point deadline_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_TIMER_H__ */ -- cgit v1.2.1