Remove the verbose #ifndef/#define/#endif pattern for maintaining header idempotency, and replace it with a simple #pragma once. This simplifies the headers, and prevents redundant changes when header files get moved. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
50 lines
936 B
C++
50 lines
936 B
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* timer.h - Generic timer
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <stdint.h>
|
|
|
|
#include <libcamera/base/private.h>
|
|
|
|
#include <libcamera/base/object.h>
|
|
#include <libcamera/base/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<> timeout;
|
|
|
|
protected:
|
|
void message(Message *msg) override;
|
|
|
|
private:
|
|
void registerTimer();
|
|
void unregisterTimer();
|
|
|
|
bool running_;
|
|
std::chrono::steady_clock::time_point deadline_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|