[{"id":33595,"web_url":"https://patchwork.libcamera.org/comment/33595/","msgid":"<174212776003.1266550.282200005647972044@ping.linuxembedded.co.uk>","date":"2025-03-16T12:22:40","subject":"Re: [PATCH v1] libcamera: request: Store fence `EventNotifier`\n\tdirectly","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-03-10 17:03:35)\n> Simplify a bit by storing the `EventNotifier` objects directly in the\n> `std::map` instead of wrapping them in unique_ptr. An other advantage\n> is that it removes one allocation per fence.\n\nThis one sounds good, and doesn't impact public API/ABI as far as I can\ntell:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  include/libcamera/internal/request.h |  2 +-\n>  src/libcamera/request.cpp            | 13 +++++--------\n>  2 files changed, 6 insertions(+), 9 deletions(-)\n> \n> diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h\n> index 73e9bb5cc..78cb99f36 100644\n> --- a/include/libcamera/internal/request.h\n> +++ b/include/libcamera/internal/request.h\n> @@ -59,7 +59,7 @@ private:\n>         bool prepared_ = false;\n>  \n>         std::unordered_set<FrameBuffer *> pending_;\n> -       std::map<FrameBuffer *, std::unique_ptr<EventNotifier>> notifiers_;\n> +       std::map<FrameBuffer *, EventNotifier> notifiers_;\n>         std::unique_ptr<Timer> timer_;\n>  };\n>  \n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index b206ac132..6fa1801a0 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -228,15 +228,12 @@ void Request::Private::prepare(std::chrono::milliseconds timeout)\n>                 if (!fence)\n>                         continue;\n>  \n> -               std::unique_ptr<EventNotifier> notifier =\n> -                       std::make_unique<EventNotifier>(fence->fd().get(),\n> -                                                       EventNotifier::Read);\n> +               auto [it, inserted] = notifiers_.try_emplace(buffer, fence->fd().get(), EventNotifier::Type::Read);\n> +               ASSERT(inserted);\n>  \n> -               notifier->activated.connect(this, [this, buffer] {\n> -                                                       notifierActivated(buffer);\n> -                                           });\n> -\n> -               notifiers_[buffer] = std::move(notifier);\n> +               it->second.activated.connect(this, [this, buffer] {\n> +                       notifierActivated(buffer);\n> +               });\n>         }\n>  \n>         if (notifiers_.empty()) {\n> -- \n> 2.48.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 B3C49C32AF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 16 Mar 2025 12:22:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CB9AD6894B;\n\tSun, 16 Mar 2025 13:22:43 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD84A68940\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Mar 2025 13:22:42 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E899873E;\n\tSun, 16 Mar 2025 13:21:01 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"diT8dC5n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742127662;\n\tbh=mRgZgnB4ZzVeYFISdoYaW7s0fKEZMO/RY2AlK84ZAtM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=diT8dC5nQFIi2UWHbLMK1ZnqTSsxTLNTcKRnZ592ws1RFKw3OnfWkZKkMRcHk+eVD\n\tjYp9T+LkrwMfP2dUDHSh1Cv29wMZxqr6MwccHFktG3YLppZ+s7q9H3MvzKr02sqTXz\n\taLYAMv1C3LYGeytT+En4JrEJQu0CsOwz4jTUKPJc=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250310170335.185297-1-barnabas.pocze@ideasonboard.com>","References":"<20250310170335.185297-1-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v1] libcamera: request: Store fence `EventNotifier`\n\tdirectly","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sun, 16 Mar 2025 12:22:40 +0000","Message-ID":"<174212776003.1266550.282200005647972044@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":36991,"web_url":"https://patchwork.libcamera.org/comment/36991/","msgid":"<umdkqz6nnk4yw6mb3qrmcf7ygpsyipz7a63rmamzcokpab7i64@oo67q2ipkwtc>","date":"2025-11-21T13:56:09","subject":"Re: [PATCH v1] libcamera: request: Store fence `EventNotifier`\n\tdirectly","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Mon, Mar 10, 2025 at 06:03:35PM +0100, Barnabás Pőcze wrote:\n> Simplify a bit by storing the `EventNotifier` objects directly in the\n> `std::map` instead of wrapping them in unique_ptr. An other advantage\n> is that it removes one allocation per fence.\n>\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nAnother one from the cracks\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nI guess you can merge this one ?\n\n> ---\n>  include/libcamera/internal/request.h |  2 +-\n>  src/libcamera/request.cpp            | 13 +++++--------\n>  2 files changed, 6 insertions(+), 9 deletions(-)\n>\n> diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h\n> index 73e9bb5cc..78cb99f36 100644\n> --- a/include/libcamera/internal/request.h\n> +++ b/include/libcamera/internal/request.h\n> @@ -59,7 +59,7 @@ private:\n>  \tbool prepared_ = false;\n>\n>  \tstd::unordered_set<FrameBuffer *> pending_;\n> -\tstd::map<FrameBuffer *, std::unique_ptr<EventNotifier>> notifiers_;\n> +\tstd::map<FrameBuffer *, EventNotifier> notifiers_;\n>  \tstd::unique_ptr<Timer> timer_;\n>  };\n>\n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index b206ac132..6fa1801a0 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -228,15 +228,12 @@ void Request::Private::prepare(std::chrono::milliseconds timeout)\n>  \t\tif (!fence)\n>  \t\t\tcontinue;\n>\n> -\t\tstd::unique_ptr<EventNotifier> notifier =\n> -\t\t\tstd::make_unique<EventNotifier>(fence->fd().get(),\n> -\t\t\t\t\t\t\tEventNotifier::Read);\n> +\t\tauto [it, inserted] = notifiers_.try_emplace(buffer, fence->fd().get(), EventNotifier::Type::Read);\n> +\t\tASSERT(inserted);\n>\n> -\t\tnotifier->activated.connect(this, [this, buffer] {\n> -\t\t\t\t\t\t\tnotifierActivated(buffer);\n> -\t\t\t\t\t    });\n> -\n> -\t\tnotifiers_[buffer] = std::move(notifier);\n> +\t\tit->second.activated.connect(this, [this, buffer] {\n> +\t\t\tnotifierActivated(buffer);\n> +\t\t});\n>  \t}\n>\n>  \tif (notifiers_.empty()) {\n> --\n> 2.48.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 F19B8C3330\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Nov 2025 13:56:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D2E860A9E;\n\tFri, 21 Nov 2025 14:56:14 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 80FD3609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Nov 2025 14:56:12 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 34B4B8E0;\n\tFri, 21 Nov 2025 14:54:06 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Nnnrtt5r\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763733246;\n\tbh=PMuY5z5Hqu9ShNdBD+GH+fefn13PGaGbXAArds2uKUY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Nnnrtt5rLrBOa+ZVRqrK2JQ4AQAQOKYzDVTCuyle5l1nOIev+MF1vvnYBAcYhnG85\n\t9uddhfNst0c3DFg8Z9KYT46eIZj2NWzVMkvlW5jdG9oMCmpjPUe8yapqfaUPr/JM/u\n\tm7qI1OBkSxJM+Sf+lF+oMJTl6B7pOr7d7yrse8fA=","Date":"Fri, 21 Nov 2025 14:56:09 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1] libcamera: request: Store fence `EventNotifier`\n\tdirectly","Message-ID":"<umdkqz6nnk4yw6mb3qrmcf7ygpsyipz7a63rmamzcokpab7i64@oo67q2ipkwtc>","References":"<20250310170335.185297-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250310170335.185297-1-barnabas.pocze@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]