[{"id":2799,"web_url":"https://patchwork.libcamera.org/comment/2799/","msgid":"<20191006182511.bhl6idgzpijf7ygi@uno.localdomain>","date":"2019-10-06T18:25:11","subject":"Re: [libcamera-devel] [PATCH 2/9] libcamera: timer: Don't reset\n\tdeadline after time out","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Sun, Oct 06, 2019 at 08:32:19AM +0300, Laurent Pinchart wrote:\n> Users of the Timer class may benefit from retrieving the timer deadline\n> after it times out. This is currently not possible as the deadline is\n> reset to 0 when the timer times out or is stopped. Fix this by not\n> resetting the deadline, and adding a new running_ field to the Timer\n> class to implement isRunning().\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/timer.h | 1 +\n>  src/libcamera/timer.cpp   | 8 ++++----\n>  2 files changed, 5 insertions(+), 4 deletions(-)\n>\n> diff --git a/include/libcamera/timer.h b/include/libcamera/timer.h\n> index 09f426a59993..3540efb41b6f 100644\n> --- a/include/libcamera/timer.h\n> +++ b/include/libcamera/timer.h\n> @@ -39,6 +39,7 @@ private:\n>  \tvoid registerTimer();\n>  \tvoid unregisterTimer();\n>\n> +\tbool running_;\n>  \tstd::chrono::steady_clock::time_point deadline_;\n>  };\n>\n> diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp\n> index 34410bab0fb0..8c74e1015e43 100644\n> --- a/src/libcamera/timer.cpp\n> +++ b/src/libcamera/timer.cpp\n> @@ -43,7 +43,7 @@ LOG_DEFINE_CATEGORY(Timer)\n>   * \\param[in] parent The parent Object\n>   */\n>  Timer::Timer(Object *parent)\n> -\t: Object(parent)\n> +\t: Object(parent), running_(false)\n>  {\n>  }\n>\n> @@ -89,17 +89,17 @@ void Timer::start(std::chrono::milliseconds duration)\n>  void Timer::stop()\n>  {\n>  \tunregisterTimer();\n> -\n> -\tdeadline_ = utils::time_point();\n>  }\n>\n>  void Timer::registerTimer()\n>  {\n>  \tthread()->eventDispatcher()->registerTimer(this);\n> +\trunning_ = true;\n>  }\n>\n>  void Timer::unregisterTimer()\n>  {\n> +\trunning_ = false;\n>  \tthread()->eventDispatcher()->unregisterTimer(this);\n>  }\n>\n> @@ -109,7 +109,7 @@ void Timer::unregisterTimer()\n>   */\n>  bool Timer::isRunning() const\n>  {\n> -\treturn deadline_ != utils::time_point();\n\nweird, i would have expected this to be deadline < utils::time_point()\n\nAnyway\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> +\treturn running_;\n>  }\n>\n>  /**\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EC21760E1E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 20:23:26 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 5990140006;\n\tSun,  6 Oct 2019 18:23:26 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Sun, 6 Oct 2019 20:25:11 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191006182511.bhl6idgzpijf7ygi@uno.localdomain>","References":"<20191006053226.8976-1-laurent.pinchart@ideasonboard.com>\n\t<20191006053226.8976-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"6fz2i7irufb25tzj\"","Content-Disposition":"inline","In-Reply-To":"<20191006053226.8976-3-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 2/9] libcamera: timer: Don't reset\n\tdeadline after time out","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sun, 06 Oct 2019 18:23:27 -0000"}},{"id":2809,"web_url":"https://patchwork.libcamera.org/comment/2809/","msgid":"<20191007025815.GG4740@pendragon.ideasonboard.com>","date":"2019-10-07T02:58:15","subject":"Re: [libcamera-devel] [PATCH 2/9] libcamera: timer: Don't reset\n\tdeadline after time out","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Sun, Oct 06, 2019 at 08:25:11PM +0200, Jacopo Mondi wrote:\n> On Sun, Oct 06, 2019 at 08:32:19AM +0300, Laurent Pinchart wrote:\n> > Users of the Timer class may benefit from retrieving the timer deadline\n> > after it times out. This is currently not possible as the deadline is\n> > reset to 0 when the timer times out or is stopped. Fix this by not\n> > resetting the deadline, and adding a new running_ field to the Timer\n> > class to implement isRunning().\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/timer.h | 1 +\n> >  src/libcamera/timer.cpp   | 8 ++++----\n> >  2 files changed, 5 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/include/libcamera/timer.h b/include/libcamera/timer.h\n> > index 09f426a59993..3540efb41b6f 100644\n> > --- a/include/libcamera/timer.h\n> > +++ b/include/libcamera/timer.h\n> > @@ -39,6 +39,7 @@ private:\n> >  \tvoid registerTimer();\n> >  \tvoid unregisterTimer();\n> >\n> > +\tbool running_;\n> >  \tstd::chrono::steady_clock::time_point deadline_;\n> >  };\n> >\n> > diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp\n> > index 34410bab0fb0..8c74e1015e43 100644\n> > --- a/src/libcamera/timer.cpp\n> > +++ b/src/libcamera/timer.cpp\n> > @@ -43,7 +43,7 @@ LOG_DEFINE_CATEGORY(Timer)\n> >   * \\param[in] parent The parent Object\n> >   */\n> >  Timer::Timer(Object *parent)\n> > -\t: Object(parent)\n> > +\t: Object(parent), running_(false)\n> >  {\n> >  }\n> >\n> > @@ -89,17 +89,17 @@ void Timer::start(std::chrono::milliseconds duration)\n> >  void Timer::stop()\n> >  {\n> >  \tunregisterTimer();\n> > -\n> > -\tdeadline_ = utils::time_point();\n> >  }\n> >\n> >  void Timer::registerTimer()\n> >  {\n> >  \tthread()->eventDispatcher()->registerTimer(this);\n> > +\trunning_ = true;\n> >  }\n> >\n> >  void Timer::unregisterTimer()\n> >  {\n> > +\trunning_ = false;\n> >  \tthread()->eventDispatcher()->unregisterTimer(this);\n> >  }\n> >\n> > @@ -109,7 +109,7 @@ void Timer::unregisterTimer()\n> >   */\n> >  bool Timer::isRunning() const\n> >  {\n> > -\treturn deadline_ != utils::time_point();\n> \n> weird, i would have expected this to be deadline < utils::time_point()\n\nutils::timer_point() is a \"zero\" time point, corresponding to the epoch.\nThe Timer class use this as a magic value to denote a non-running timer.\nThat's what this patch removes.\n\n> Anyway\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> > +\treturn running_;\n> >  }\n> >\n> >  /**","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E46D96157C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Oct 2019 04:58:18 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(modemcable151.96-160-184.mc.videotron.ca [184.160.96.151])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1427FDD;\n\tMon,  7 Oct 2019 04:58:17 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570417098;\n\tbh=CNO7pVfB4d4edwJrR5/s+I7mSVp3us2HHjcKWsfx1Ts=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=EaMfwdeRIz9TtR9czBBG89oNKt6CAWnd0lVxfhtfHwHzFxv4FLB38BN+xNHScb7O6\n\tOXiNrtU4FtDgJjqGYH1lG7G1HPQv42t0d0pkgubt21U5N/y3xv7inWkkTxXI5aFkPE\n\tOF/x2N8kGhAvr16RkzfP+OnwcLV+z2ctbbkQTZEc=","Date":"Mon, 7 Oct 2019 05:58:15 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191007025815.GG4740@pendragon.ideasonboard.com>","References":"<20191006053226.8976-1-laurent.pinchart@ideasonboard.com>\n\t<20191006053226.8976-3-laurent.pinchart@ideasonboard.com>\n\t<20191006182511.bhl6idgzpijf7ygi@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191006182511.bhl6idgzpijf7ygi@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 2/9] libcamera: timer: Don't reset\n\tdeadline after time out","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 07 Oct 2019 02:58:19 -0000"}}]