Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Generic timer
*/
#pragma once
#include <chrono>
#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(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 */
libcamera::Message
A message that can be posted to a Thread.
Definition message.h:24
libcamera::Object::Object
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
libcamera::Object::parent
Object * parent() const
Retrieve the object's parent.
Definition object.h:49
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera::Timer::isRunning
bool isRunning() const
Check if the timer is running.
Definition timer.cpp:140
libcamera::Timer::message
void message(Message *msg) override
Message handler for the object.
Definition timer.cpp:158
libcamera::Timer::start
void start(std::chrono::milliseconds duration)
Start or restart the timer with a timeout of duration.
Definition timer.cpp:73
libcamera::Timer::timeout
Signal timeout
Signal emitted when the timer times out.
Definition timer.h:34
libcamera::Timer::stop
void stop()
Stop the timer.
Definition timer.cpp:113
libcamera::Timer::Timer
Timer(Object *parent=nullptr)
Construct a timer.
Definition timer.cpp:55
libcamera::Timer::deadline
std::chrono::steady_clock::time_point deadline() const
Retrieve the timer deadline.
Definition timer.h:32
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
object.h
Base object to support automatic signal disconnection.
signal.h
Signal & slot implementation.