mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 23:39:44 +03:00
test: timer: Test that deadline() isn't reset upon time out
Verify that the timer deadline stays valid after the timer expires. As the test now uses the deadline in order to compute the jitter, the interval_ field isn't used anymore and can be removed. 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>
This commit is contained in:
parent
36c35345fa
commit
9c6794164d
1 changed files with 3 additions and 6 deletions
|
@ -21,14 +21,13 @@ class ManagedTimer : public Timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ManagedTimer()
|
ManagedTimer()
|
||||||
: Timer(), interval_(0)
|
: Timer()
|
||||||
{
|
{
|
||||||
timeout.connect(this, &ManagedTimer::timeoutHandler);
|
timeout.connect(this, &ManagedTimer::timeoutHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void start(int msec)
|
void start(int msec)
|
||||||
{
|
{
|
||||||
interval_ = msec;
|
|
||||||
start_ = std::chrono::steady_clock::now();
|
start_ = std::chrono::steady_clock::now();
|
||||||
expiration_ = std::chrono::steady_clock::time_point();
|
expiration_ = std::chrono::steady_clock::time_point();
|
||||||
|
|
||||||
|
@ -37,9 +36,8 @@ public:
|
||||||
|
|
||||||
int jitter()
|
int jitter()
|
||||||
{
|
{
|
||||||
std::chrono::steady_clock::duration duration = expiration_ - start_;
|
std::chrono::steady_clock::duration duration = expiration_ - deadline();
|
||||||
int msecs = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
|
return abs(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
|
||||||
return abs(msecs - interval_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -48,7 +46,6 @@ private:
|
||||||
expiration_ = std::chrono::steady_clock::now();
|
expiration_ = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
int interval_;
|
|
||||||
std::chrono::steady_clock::time_point start_;
|
std::chrono::steady_clock::time_point start_;
|
||||||
std::chrono::steady_clock::time_point expiration_;
|
std::chrono::steady_clock::time_point expiration_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue