[{"id":25263,"web_url":"https://patchwork.libcamera.org/comment/25263/","msgid":"<YzxZ4mYD+3lz51TX@pendragon.ideasonboard.com>","date":"2022-10-04T16:05:54","subject":"Re: [libcamera-devel] [PATCH v3 1/7] delayed_controls: Template the\n\tControlRingBuffer class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, Sep 26, 2022 at 10:57:31AM +0100, Naushir Patuck via libcamera-devel wrote:\n> Convert ControlRingBuffer to a templated class to allow arbitrary ring buffer\n> array types to be defined. Rename ControlRingBuffer to RingBuffer to indicate\n> this.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> Tested-by: David Plowman <david.plowman@raspberrypi.com>\n\nThis patch looks fine, so\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nI'll now look at how it's used :-)\n\n> ---\n>  include/libcamera/internal/delayed_controls.h | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h\n> index aef37077103c..de8026e3e4f0 100644\n> --- a/include/libcamera/internal/delayed_controls.h\n> +++ b/include/libcamera/internal/delayed_controls.h\n> @@ -53,17 +53,18 @@ private:\n>  \n>  \t/* \\todo Make the listSize configurable at instance creation time. */\n>  \tstatic constexpr int listSize = 16;\n> -\tclass ControlRingBuffer : public std::array<Info, listSize>\n> +\ttemplate<typename T>\n> +\tclass RingBuffer : public std::array<T, listSize>\n>  \t{\n>  \tpublic:\n> -\t\tInfo &operator[](unsigned int index)\n> +\t\tT &operator[](unsigned int index)\n>  \t\t{\n> -\t\t\treturn std::array<Info, listSize>::operator[](index % listSize);\n> +\t\t\treturn std::array<T, listSize>::operator[](index % listSize);\n>  \t\t}\n>  \n> -\t\tconst Info &operator[](unsigned int index) const\n> +\t\tconst T &operator[](unsigned int index) const\n>  \t\t{\n> -\t\t\treturn std::array<Info, listSize>::operator[](index % listSize);\n> +\t\t\treturn std::array<T, listSize>::operator[](index % listSize);\n>  \t\t}\n>  \t};\n>  \n> @@ -75,7 +76,7 @@ private:\n>  \tuint32_t queueCount_;\n>  \tuint32_t writeCount_;\n>  \t/* \\todo Evaluate if we should index on ControlId * or unsigned int */\n> -\tstd::unordered_map<const ControlId *, ControlRingBuffer> values_;\n> +\tstd::unordered_map<const ControlId *, RingBuffer<Info>> values_;\n>  };\n>  \n>  } /* namespace libcamera */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8D3F6C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Oct 2022 16:05:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B94FA60AAB;\n\tTue,  4 Oct 2022 18:05:58 +0200 (CEST)","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 B445F601C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Oct 2022 18:05:57 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0ECF52D9;\n\tTue,  4 Oct 2022 18:05:56 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664899558;\n\tbh=mHecwtjpMagFCJooX2aTLugy7tFatJA99szqNWlFxcQ=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=QeV/fMnsr14DShGHpsCkfh+oQmapfK1QkEFKQpqv7P3R7a/ftRd+KadESc325LZk7\n\tB4id9oq5SeedDD/rEyNyGVpNIhakKW3k5rfnGNCHpFLjG7PXQPDDPFXwQHnjz4MAzy\n\tH0PmOy1OZGH5s16PUoPggBWWuq72yqFpRGbIBHLok+9azYPjkfKBo1sSBUObchh5c7\n\t9OrjVjEZhuw+uDkccQ+VaugSsjHMAAb/FpQoJVPBEaxJfyC3u9WvDgge+ehGqk5F+p\n\tEi7yGIcuCYyLc9lrGSWE3M4p9q+of6r8EeCAyRcwpQzmw05XlxTvQh1Ga2EztsrWFz\n\t6vdtaDqtivgrw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664899557;\n\tbh=mHecwtjpMagFCJooX2aTLugy7tFatJA99szqNWlFxcQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vFY29JwwWGHzybJOY8FEtn/lhrZxRKPKBuVcyumsvdx/45JzNrRN9Vi2qTYRIvzJs\n\t+0LV5FrxWlMeb2kYK6CDvAezsTgn3jRZBdTZAR3FgVYXl20VdA2XHI67xexw5xzP+/\n\t8sHuT7qLECxHLY6HoG58Z86LmU7GlxgeLa2YBnqc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"vFY29Jww\"; dkim-atps=neutral","Date":"Tue, 4 Oct 2022 19:05:54 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YzxZ4mYD+3lz51TX@pendragon.ideasonboard.com>","References":"<20220926095737.30506-1-naush@raspberrypi.com>\n\t<20220926095737.30506-2-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220926095737.30506-2-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 1/7] delayed_controls: Template the\n\tControlRingBuffer class","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]