Show a patch.

GET /api/1.1/patches/24089/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 24089,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/24089/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24089/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250811094926.1308259-2-barnabas.pocze@ideasonboard.com>",
    "date": "2025-08-11T09:49:25",
    "name": "[RFC,v1,1/2] libcamera: base: object: Add `invokeMethod` for lamdas",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "cbd462663e262a8f5975aeef867587a4d9656c3f",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24089/mbox/",
    "series": [
        {
            "id": 5365,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5365/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5365",
            "date": "2025-08-11T09:49:24",
            "name": "libcamera: pipeline: virtual: Move image generation to separate thread",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5365/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24089/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24089/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 55531BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Aug 2025 09:49:34 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C864969230;\n\tMon, 11 Aug 2025 11:49:31 +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 CAFB761464\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Aug 2025 11:49:29 +0200 (CEST)",
            "from pb-laptop.local (185.221.140.182.nat.pool.zt.hu\n\t[185.221.140.182])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C997C10D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Aug 2025 11:48:37 +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=\"BU5JXXQZ\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754905717;\n\tbh=+aU5QbLxj/hcBEzsskTkS6MZzydYuIlSDc5zFp7SyGc=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=BU5JXXQZGQJgfOscnKjEcmUQ2HbUfuTYN+wLBpRJBVCNB+gY1TOHV+hufPQGtTD/4\n\tmGr3LGaP8RmJopGgUtTTxTG9QILoZ+fJ4dApmma/q6IWR9xUtuJeitZvXkYNCtLZWD\n\tHMee7xxhc98IlidXfSM7vi2I91bvKi6w82AIEhmQ=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[RFC PATCH v1 1/2] libcamera: base: object: Add `invokeMethod` for\n\tlamdas",
        "Date": "Mon, 11 Aug 2025 11:49:25 +0200",
        "Message-ID": "<20250811094926.1308259-2-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.50.1",
        "In-Reply-To": "<20250811094926.1308259-1-barnabas.pocze@ideasonboard.com>",
        "References": "<20250811094926.1308259-1-barnabas.pocze@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": "Add an overload of `invokeMethod` that works the same way as the already\nexisting version but instead of invoking a particular member function,\nit runs a lambda.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/base/object.h | 10 ++++++++++\n src/libcamera/base/object.cpp   | 24 +++++++++++++++++++++++-\n 2 files changed, 33 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/base/object.h b/include/libcamera/base/object.h\nindex a24f84ff9..3f004499f 100644\n--- a/include/libcamera/base/object.h\n+++ b/include/libcamera/base/object.h\n@@ -43,6 +43,16 @@ public:\n \t\treturn method->activate(std::forward<Args>(args)..., true);\n \t}\n \n+\ttemplate<typename Func,\n+\t\t std::enable_if_t<std::is_invocable_v<Func&>> * = nullptr>\n+\tauto invokeMethod(Func func, ConnectionType type)\n+\t\t-> std::invoke_result_t<Func&>\n+\t{\n+\t\tusing R = std::invoke_result_t<Func&>;\n+\t\tauto *method = new BoundMethodFunctor<Object, R, Func>(this, this, std::move(func), type);\n+\t\treturn method->activate(true);\n+\t}\n+\n \tThread *thread() const { return thread_; }\n \tvoid moveToThread(Thread *thread);\n \ndiff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp\nindex 37d133cc7..98937784c 100644\n--- a/src/libcamera/base/object.cpp\n+++ b/src/libcamera/base/object.cpp\n@@ -255,7 +255,7 @@ bool Object::assertThreadBound(const char *message)\n }\n \n /**\n- * \\fn R Object::invokeMethod()\n+ * \\fn Object::invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type, Args &&...args)\n  * \\brief Invoke a method asynchronously on an Object instance\n  * \\param[in] func The object method to invoke\n  * \\param[in] type Connection type for method invocation\n@@ -280,6 +280,28 @@ bool Object::assertThreadBound(const char *message)\n  * connection type ConnectionTypeQueued, return a default-constructed R value.\n  */\n \n+/**\n+ * \\fn Object::invokeMethod(Func func, ConnectionType type)\n+ * \\brief Invoke a lambda in the thread of an Object instance\n+ * \\param[in] func The object method to invoke\n+ * \\param[in] type Connection type for method invocation\n+ *\n+ * This function invokes the lambda \\a func without arguments, based on the\n+ * connection \\a type wrt. the Object instance. Depending on the type, the method\n+ * will be called synchronously in the same thread or asynchronously in the\n+ * object's thread.\n+ *\n+ * Due to the asynchronous nature of threads, asynchronous invocations with the\n+ * ConnectionTypeQueued type are not guaranteed to be called before the thread\n+ * is stopped. See \\ref thread-stop for additional information.\n+ *\n+ * \\context This function is \\threadsafe.\n+ *\n+ * \\return For connection types ConnectionTypeDirect and\n+ * ConnectionTypeBlocking, return the return value of the invoked method. For\n+ * connection type ConnectionTypeQueued, return a default-constructed R value.\n+ */\n+\n /**\n  * \\fn Object::thread()\n  * \\brief Retrieve the thread the object is bound to\n",
    "prefixes": [
        "RFC",
        "v1",
        "1/2"
    ]
}