Patch Detail
Show a patch.
GET /api/patches/24058/?format=api
{ "id": 24058, "url": "https://patchwork.libcamera.org/api/patches/24058/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24058/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250804233152.11538-2-laurent.pinchart@ideasonboard.com>", "date": "2025-08-04T23:31:50", "name": "[v4,1/2] libcamera: utils: Add scope_exit class", "commit_ref": "6ef2d79a730b79e7cb075678f81b327637a3d29f", "pull_url": null, "state": "accepted", "archived": false, "hash": "8bd1c35becbf2350bc665d37c9b2f96362f77a4c", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24058/mbox/", "series": [ { "id": 5357, "url": "https://patchwork.libcamera.org/api/series/5357/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5357", "date": "2025-08-04T23:31:49", "name": "libcamera: Introduce and use scope_exit", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5357/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24058/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24058/checks/", "tags": {}, "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 183A3BE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 4 Aug 2025 23:32:11 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 197E56921F;\n\tTue, 5 Aug 2025 01:32:09 +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 46E1061466\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 5 Aug 2025 01:32:07 +0200 (CEST)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id D804332FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 5 Aug 2025 01:31:19 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nPMV0v0x\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754350280;\n\tbh=PC79loi6tuM6S81Xde7CNaAGYlaYDb0e/KopDPB9vJ0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=nPMV0v0xgIKPzC93KMWg6ibparOcCyulJi3Qr4lU9mhmKKf8kY/WURhedmQtYsf4W\n\t5NvJH09CaCMUOehenFStrS3cRbykadCnU/XYc4jIW22CKdcsOVnZBWi1Uqz39mKmA4\n\tY9BzXeQhnC3r3mtBmeMYraNm6D3kcwAYImjB/+a0=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v4 1/2] libcamera: utils: Add scope_exit class", "Date": "Tue, 5 Aug 2025 02:31:50 +0300", "Message-ID": "<20250804233152.11538-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.49.1", "In-Reply-To": "<20250804233152.11538-1-laurent.pinchart@ideasonboard.com>", "References": "<20250804233152.11538-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "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>" }, "content": "The scope_exit class is an implementation of the identically named C++\nlibrary fundamentals TS v3 class, as documented in [1]. It is a simpler\nversion of the libcamera-specific ScopeExitActions class and doesn't\nrequire dynamic heap memory allocation, making it more suitable for hot\npaths.\n\nThe class is not documented as it implements a C++ standard (even if\nexperimental) API.\n\n[1] https://en.cppreference.com/w/cpp/experimental/scope_exit/scope_exit.html\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nChanges since v3:\n\n- Use LIBCAMERA_DISABLE_COPY_AND_MOVE()\n\nChanges since v2:\n\n- Drop lvalue reference constraint in constructor\n- Delete move constructor\n---\n include/libcamera/base/utils.h | 38 ++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)", "diff": "diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h\nindex 8d5c35782ee3..f21c6dc016ec 100644\n--- a/include/libcamera/base/utils.h\n+++ b/include/libcamera/base/utils.h\n@@ -21,6 +21,7 @@\n #include <utility>\n #include <vector>\n \n+#include <libcamera/base/class.h>\n #include <libcamera/base/private.h>\n \n #ifndef __DOXYGEN__\n@@ -428,6 +429,43 @@ private:\n \tstd::vector<std::function<void()>> actions_;\n };\n \n+#ifndef __DOXYGEN__\n+template<typename EF>\n+class scope_exit\n+{\n+public:\n+\ttemplate<typename Fn,\n+\t\t std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Fn>>, scope_exit> &&\n+\t\t\t\t std::is_constructible_v<EF, Fn>> * = nullptr>\n+\texplicit scope_exit(Fn &&fn)\n+\t\t: exitFunction_(std::forward<Fn>(fn))\n+\t{\n+\t\tstatic_assert(std::is_nothrow_constructible_v<EF, Fn>);\n+\t}\n+\n+\t~scope_exit()\n+\t{\n+\t\tif (active_)\n+\t\t\texitFunction_();\n+\t}\n+\n+\tvoid release()\n+\t{\n+\t\tactive_ = false;\n+\t}\n+\n+private:\n+\tLIBCAMERA_DISABLE_COPY_AND_MOVE(scope_exit)\n+\n+\tEF exitFunction_;\n+\tbool active_ = true;\n+};\n+\n+template<typename EF>\n+scope_exit(EF) -> scope_exit<EF>;\n+\n+#endif /* __DOXYGEN__ */\n+\n } /* namespace utils */\n \n #ifndef __DOXYGEN__\n", "prefixes": [ "v4", "1/2" ] }