summaryrefslogtreecommitdiff
path: root/include/libcamera/internal/timer.h
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-11-08 01:14:38 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-11-15 22:21:28 +0200
commitd767c84022559e55708f24a3a264853c0142135e (patch)
tree9b104f71819804d002039fab9be25340e90bc210 /include/libcamera/internal/timer.h
parent7d35c771c0480e1ca5942ba3c9cf09c1fde22f85 (diff)
libcamera: Move EventDispatcher to internal API
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'include/libcamera/internal/timer.h')
-rw-r--r--include/libcamera/internal/timer.h49
1 files changed, 49 insertions, 0 deletions
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 <chrono>
+#include <stdint.h>
+
+#include <libcamera/object.h>
+#include <libcamera/signal.h>
+
+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<Timer *> 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__ */