libcamera/include/libcamera/timer.h
Laurent Pinchart ca260d2f53 libcamera: Standardise on C compatibility headers
Now that our usage of C compatibility header is documented, use them
consistently through the source code.

While at it, group the C and C++ include statements as defined in the
coding style, and fix a handful of #include ordering issues.

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>
2019-10-23 17:39:39 +03:00

49 lines
978 B
C++

/* 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__ */