[{"id":25609,"web_url":"https://patchwork.libcamera.org/comment/25609/","msgid":"<166680072575.2677993.6868670891795811442@Monstersaurus>","date":"2022-10-26T16:12:05","subject":"Re: [libcamera-devel] [PATCH v4 1/7] delayed_controls: Template the\n\tControlRingBuffer class","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nQuoting Naushir Patuck via libcamera-devel (2022-10-19 10:01:01)\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\nI know Laurent has been investigating 'generic' ring-buffer\nimplementations, but that sounded like it grew into a rabbit hole, and\nthis is quite localised.\n\nI can see it's going to help later in the series, and it doesn't impact\nanything else here so:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\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>         /* \\todo Make the listSize configurable at instance creation time. */\n>         static constexpr int listSize = 16;\n> -       class ControlRingBuffer : public std::array<Info, listSize>\n> +       template<typename T>\n> +       class RingBuffer : public std::array<T, listSize>\n>         {\n>         public:\n> -               Info &operator[](unsigned int index)\n> +               T &operator[](unsigned int index)\n>                 {\n> -                       return std::array<Info, listSize>::operator[](index % listSize);\n> +                       return std::array<T, listSize>::operator[](index % listSize);\n>                 }\n>  \n> -               const Info &operator[](unsigned int index) const\n> +               const T &operator[](unsigned int index) const\n>                 {\n> -                       return std::array<Info, listSize>::operator[](index % listSize);\n> +                       return std::array<T, listSize>::operator[](index % listSize);\n>                 }\n>         };\n>  \n> @@ -75,7 +76,7 @@ private:\n>         uint32_t queueCount_;\n>         uint32_t writeCount_;\n>         /* \\todo Evaluate if we should index on ControlId * or unsigned int */\n> -       std::unordered_map<const ControlId *, ControlRingBuffer> values_;\n> +       std::unordered_map<const ControlId *, RingBuffer<Info>> values_;\n>  };\n>  \n>  } /* namespace libcamera */\n> -- \n> 2.25.1\n>","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 7EF8CBDB16\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Oct 2022 16:12:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 97FB762F5C;\n\tWed, 26 Oct 2022 18:12:10 +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 1D83961F4B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Oct 2022 18:12:09 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 970844F8;\n\tWed, 26 Oct 2022 18:12:08 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666800730;\n\tbh=54Wgs/KKhhJnXMI/Cw14+bRHcnZrkdGTmUkXI8Jlcgc=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=DwQL4be9A+l8IZ9K5OTI70Bac5NfAVCKKQ46BS6Yq5zSdyHULGSn9Q+S2DE4J88Pz\n\t22SL/kCAAb6khcbCq5FtXkYz3iWGH71hRGyqW2GkvQD1ffjdVwDox7AE326sISiImt\n\t/ZKXAOtJzr4sq/BWQAy2WX9MEnqVDJ7UUkrcThIu1QxqYlVJI+h/4p03CPuslk+chD\n\tb8bfHggRZEoxAZTjhTwsU711zWvDKy2JL3BSDPvcVbwd69yh1A+oLx1aKvAQGAFKW7\n\ti3qc8sAlBg7baUzDZLMZGnk2DKOMKy6XuF/7hMBoZ8vU8T/qqPTV5oXgH3WdA1FIau\n\tAjbQwloSAWkMw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666800728;\n\tbh=54Wgs/KKhhJnXMI/Cw14+bRHcnZrkdGTmUkXI8Jlcgc=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=OYAmVBBu7j1vRSgKnzLw5pWWCuGNdIwOfmenVakmuD/Az6q3pobRHFd2lKaOycGAk\n\trFyzx6XkYGvVhztZIUeh17HNRG+8Jf8j3321WBd4/VGiA9FY6jzXh13/+ksYHiGbI2\n\tXoxhA4wzswae4Sq0MkHr4U1HK/qAnx8S6u8537MQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OYAmVBBu\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20221019090107.19975-2-naush@raspberrypi.com>","References":"<20221019090107.19975-1-naush@raspberrypi.com>\n\t<20221019090107.19975-2-naush@raspberrypi.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 26 Oct 2022 17:12:05 +0100","Message-ID":"<166680072575.2677993.6868670891795811442@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v4 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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]