libcamera/include/libcamera/timer.h
Laurent Pinchart e85f42110f libcamera: timer: Remove the interval() method
The libcamera timers are single-shot timers. They are started with a
duration, but fire once only, not based on an interval. Remove the
interval concept by removing the interval() method, and rename other
occurences of interval to duration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-07 06:02:16 +03:00

47 lines
900 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 <cstdint>
#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 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();
std::chrono::steady_clock::time_point deadline_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_TIMER_H__ */