From patchwork Sun Oct 6 05:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2108 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 37BD561967 for ; Sun, 6 Oct 2019 07:32:37 +0200 (CEST) Received: from pendragon.ideasonboard.com (modemcable151.96-160-184.mc.videotron.ca [184.160.96.151]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 54A9273E for ; Sun, 6 Oct 2019 07:32:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1570339956; bh=kEGCTuidhIjcKppbkB5bxzA/zzUVL1xO20g5whvZ3Fs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=asJ+wcj2Z8ou5u5m26S5JXtFZQT4GtCiKhQn/a6dLII2O2qte6M8g0nQNnaYDpics gE5NoVJ3XU1k6GvGT+6nvsidW+yx+ey2FAuw7qDT70SvzPkOk3WULreh/YC8H6mo4h YBOtmX4FB0pt+IaQk84n6wjHa8GApTYTyEl5NHYA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 6 Oct 2019 08:32:20 +0300 Message-Id: <20191006053226.8976-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191006053226.8976-1-laurent.pinchart@ideasonboard.com> References: <20191006053226.8976-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/9] test: timer: Test that deadline() isn't reset upon time out X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Oct 2019 05:32:37 -0000 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 Reviewed-by: Jacopo Mondi --- test/timer.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/timer.cpp b/test/timer.cpp index af922cb371cd..d4f16a9bdd97 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -21,14 +21,13 @@ class ManagedTimer : public Timer { public: ManagedTimer() - : Timer(), interval_(0) + : Timer() { timeout.connect(this, &ManagedTimer::timeoutHandler); } void start(int msec) { - interval_ = msec; start_ = std::chrono::steady_clock::now(); expiration_ = std::chrono::steady_clock::time_point(); @@ -37,9 +36,8 @@ public: int jitter() { - std::chrono::steady_clock::duration duration = expiration_ - start_; - int msecs = std::chrono::duration_cast(duration).count(); - return abs(msecs - interval_); + std::chrono::steady_clock::duration duration = expiration_ - deadline(); + return abs(std::chrono::duration_cast(duration).count()); } private: @@ -48,7 +46,6 @@ private: expiration_ = std::chrono::steady_clock::now(); } - int interval_; std::chrono::steady_clock::time_point start_; std::chrono::steady_clock::time_point expiration_; };