From patchwork Mon Mar 10 17:03:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22947 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CB7FCC32F1 for ; Mon, 10 Mar 2025 17:03:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6F6AC68920; Mon, 10 Mar 2025 18:03:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EPCxeaqH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A7EB687F0 for ; Mon, 10 Mar 2025 18:03:41 +0100 (CET) Received: from pb-laptop.local (185.221.143.221.nat.pool.zt.hu [185.221.143.221]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 18CBA227 for ; Mon, 10 Mar 2025 18:02:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1741626124; bh=aEfP9AeNqiqfLnmsCO6iPblvlvXmIz0A89NTs35W+d8=; h=From:To:Subject:Date:From; b=EPCxeaqH61FFSBlkOIfXzJ/pOexZtHNxZxazsnMB8g6hqhdQr3QTlRwjcmoZ6S+M3 QHkgDiJA5p47dkoRzhGBDHOfTt7VcxQdGwhNFuWjxddynW/Bm8eeMjZkh0MhnSXjz4 sDCba1vTFFO9Ganf53pJreJvN8P4/mkc8zEQC/0I= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] libcamera: request: Store fence `EventNotifier` directly Date: Mon, 10 Mar 2025 18:03:35 +0100 Message-ID: <20250310170335.185297-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Simplify a bit by storing the `EventNotifier` objects directly in the `std::map` instead of wrapping them in unique_ptr. An other advantage is that it removes one allocation per fence. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- include/libcamera/internal/request.h | 2 +- src/libcamera/request.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h index 73e9bb5cc..78cb99f36 100644 --- a/include/libcamera/internal/request.h +++ b/include/libcamera/internal/request.h @@ -59,7 +59,7 @@ private: bool prepared_ = false; std::unordered_set pending_; - std::map> notifiers_; + std::map notifiers_; std::unique_ptr timer_; }; diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index b206ac132..6fa1801a0 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -228,15 +228,12 @@ void Request::Private::prepare(std::chrono::milliseconds timeout) if (!fence) continue; - std::unique_ptr notifier = - std::make_unique(fence->fd().get(), - EventNotifier::Read); + auto [it, inserted] = notifiers_.try_emplace(buffer, fence->fd().get(), EventNotifier::Type::Read); + ASSERT(inserted); - notifier->activated.connect(this, [this, buffer] { - notifierActivated(buffer); - }); - - notifiers_[buffer] = std::move(notifier); + it->second.activated.connect(this, [this, buffer] { + notifierActivated(buffer); + }); } if (notifiers_.empty()) {