Show a patch.

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

{
    "id": 9042,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/9042/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9042/",
    "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": "<20200728105541.13326-2-email@uajain.com>",
    "date": "2020-07-28T10:57:24",
    "name": "[libcamera-devel,1/2] libcamera: object: Add deleteLater() support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4b35f9d36fd17a4a34a7bf7ca2a6b97516e8ad6b",
    "submitter": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/people/1/?format=api",
        "name": "Umang Jain",
        "email": "email@uajain.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9042/mbox/",
    "series": [
        {
            "id": 1156,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1156/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1156",
            "date": "2020-07-28T10:57:21",
            "name": "Add Object::deleteLater() support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1156/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9042/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9042/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 62448BD878\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Jul 2020 10:57:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32CA161759;\n\tTue, 28 Jul 2020 12:57:27 +0200 (CEST)",
            "from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E575A6039B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jul 2020 12:57:25 +0200 (CEST)",
            "by filterdrecv-p3iad2-5b55dcd864-84x54 with SMTP id\n\tfilterdrecv-p3iad2-5b55dcd864-84x54-18-5F200494-18\n\t2020-07-28 10:57:24.479978629 +0000 UTC m=+2742475.743905900",
            "from mail.uajain.com (unknown)\n\tby ismtpd0001p1maa1.sendgrid.net (SG) with ESMTP id\n\tvP320OecRi6MsKsG2oGnqA for <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jul 2020 10:57:23.770 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"Nwar5nty\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=VeeHnwew9gS/uG5mNf1I1wZ/euvkn7rIzWzPRgxZQ3A=;\n\tb=Nwar5ntymOSRnFj1BlfSxWQE22w2/XMHidnNOZ1kId51O8rqplhcwhSmJf5siK3Httfb\n\tFVqZWhHTFQbCW0typYnVKfXAAzIjI3+2FFxwm9UyRW3j0PWP/WpbVqAEO/8G4BCVEW9Yhg\n\tD4LuvQjw5w920eV+yZ+hWtBeVsFWp6yEY=",
        "From": "Umang Jain <email@uajain.com>",
        "Date": "Tue, 28 Jul 2020 10:57:24 +0000 (UTC)",
        "Message-Id": "<20200728105541.13326-2-email@uajain.com>",
        "In-Reply-To": "<20200728105541.13326-1-email@uajain.com>",
        "References": "<20200728105541.13326-1-email@uajain.com>",
        "Mime-Version": "1.0",
        "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcHFp8snzxo7RIC2IEYmqCh5+cgNe1vrAZATSbtvOdAd8W9VO/L9q/pYMJ+oKs4itKpcNTySbNdT0iiOjLJzsiN+2dZHSVReLIxAagA4UM+19AKMWUe57r9SPa00XVsIXCvbUHwobq2r7rbU91slABW5zDdv26hWSRcmfacKrEGfeYVy1DsWrhrGy72Oj9sFLbEKs+RBQNgHVRq07ohBxjgA==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: object: Add deleteLater()\n\tsupport",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "This commit adds support to schedule the deletion of an Object to the\nthread it is bound to (similar to [1]). An Object getting destroyed\nby a different thread, is considered as a violation as per the\nthreading model.\n\nThis will be useful for an Object where its ownership is shared via\nshared pointers in different threads. If the thread which drops the\nlast reference of the Object is a different thread, the destructors\nget called in that particular thread, not the one Object is bound to.\nHence, in order to resolve this kind of situation, the creation of\nshared pointer can be accompanied by a custom deleter which in turns\nuse deleteLater() to ensure the Object is destroyed in its own thread.\n\n[1] https://doc.qt.io/qt-5/qobject.html#deleteLater\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n include/libcamera/internal/message.h |  1 +\n include/libcamera/object.h           |  2 ++\n src/libcamera/object.cpp             | 20 ++++++++++++++++++++\n 3 files changed, 23 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/message.h b/include/libcamera/internal/message.h\nindex 92ea64a..f1b133b 100644\n--- a/include/libcamera/internal/message.h\n+++ b/include/libcamera/internal/message.h\n@@ -25,6 +25,7 @@ public:\n \t\tNone = 0,\n \t\tInvokeMessage = 1,\n \t\tThreadMoveMessage = 2,\n+\t\tDeferredDelete = 3,\n \t\tUserMessage = 1000,\n \t};\n \ndiff --git a/include/libcamera/object.h b/include/libcamera/object.h\nindex 9a3dd07..a1882f0 100644\n--- a/include/libcamera/object.h\n+++ b/include/libcamera/object.h\n@@ -27,6 +27,8 @@ public:\n \tObject(Object *parent = nullptr);\n \tvirtual ~Object();\n \n+\tvoid deleteLater();\n+\n \tvoid postMessage(std::unique_ptr<Message> msg);\n \n \ttemplate<typename T, typename R, typename... FuncArgs, typename... Args,\ndiff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp\nindex 1544a23..93e683a 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -98,6 +98,22 @@ Object::~Object()\n \t\tchild->parent_ = nullptr;\n }\n \n+/**\n+ * \\brief Defer the deletion of Object instance to their thread\n+ *\n+ * Schedule deletion of the Object in the thread to which they are bound.\n+ * This will prevent destroying the Object from a different thread, which is\n+ * not allowed by the threading model.\n+ *\n+ * It will typically be used with a custom deleter when creating a shared\n+ * pointer. It can then be ensured that the Object is deleted in its\n+ * own thread even if its last reference is dropped in a different thread.\n+ */\n+void Object::deleteLater()\n+{\n+\tpostMessage(std::make_unique<Message>(Message::DeferredDelete));\n+}\n+\n /**\n  * \\brief Post a message to the object's thread\n  * \\param[in] msg The message\n@@ -143,6 +159,10 @@ void Object::message(Message *msg)\n \n \t\tbreak;\n \t}\n+\tcase Message::DeferredDelete: {\n+\t\tdelete this;\n+\t\tbreak;\n+\t}\n \n \tdefault:\n \t\tbreak;\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}