Show a patch.

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

{
    "id": 1785,
    "url": "https://patchwork.libcamera.org/api/patches/1785/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1785/",
    "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": "<20190812124642.24287-8-laurent.pinchart@ideasonboard.com>",
    "date": "2019-08-12T12:46:31",
    "name": "[libcamera-devel,07/18] libcamera: object: Notify objects of thread move",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "834c2469aa024d57299121a1ddcf1226923edec4",
    "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/1785/mbox/",
    "series": [
        {
            "id": 455,
            "url": "https://patchwork.libcamera.org/api/series/455/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=455",
            "date": "2019-08-12T12:46:24",
            "name": "Object & Thread enhancements",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/455/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1785/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1785/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "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 8487D61948\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2019 14:46:51 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2532F594\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2019 14:46:51 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1565614011;\n\tbh=FIDTwUk9LGgahplfudWCBnnAVDIp1mC/B2/Ibk8v/Pk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=UCg+Fasa3YhVGjUZEH/oVG+Qo2jU5HqmShYiEPSCp0vTvZte3vfj9eP9nVEQxkbnd\n\trA7VysMs7xhDG6Y7cVGlvC6WmVb/iFgLp1+aU7M+1WA+bluhwR9GWq0EIyuLduIgKI\n\tyC5nYvpRp4Yu+lGqmmDYba2ibyhNRYxlyN8R+xhg=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 12 Aug 2019 15:46:31 +0300",
        "Message-Id": "<20190812124642.24287-8-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190812124642.24287-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190812124642.24287-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 07/18] libcamera: object: Notify objects\n\tof thread move",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Mon, 12 Aug 2019 12:46:53 -0000"
    },
    "content": "Send a synchronous message to objects just before they get moved to a\nnew thread. This allows the object to perform any required processing.\nEventNotifier and Timer objects will use this mechanism to move\nthemselves to the new thread's event disaptcher.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/object.h      |  3 +++\n src/libcamera/include/message.h |  1 +\n src/libcamera/message.cpp       |  2 ++\n src/libcamera/object.cpp        | 26 ++++++++++++++++++++++++++\n 4 files changed, 32 insertions(+)",
    "diff": "diff --git a/include/libcamera/object.h b/include/libcamera/object.h\nindex 869200a57d8c..14b939a9bd3d 100644\n--- a/include/libcamera/object.h\n+++ b/include/libcamera/object.h\n@@ -27,6 +27,7 @@ public:\n \tvirtual ~Object();\n \n \tvoid postMessage(std::unique_ptr<Message> msg);\n+\tvoid sendMessage(Message *msg);\n \n \ttemplate<typename T, typename... Args, typename std::enable_if<std::is_base_of<Object, T>::value>::type * = nullptr>\n \tvoid invokeMethod(void (T::*func)(Args...), Args... args)\n@@ -52,6 +53,8 @@ private:\n \n \tvoid invokeMethod(BoundMethodBase *method, void *pack);\n \n+\tvoid notifyThreadMove();\n+\n \tvoid connect(SignalBase *signal);\n \tvoid disconnect(SignalBase *signal);\n \ndiff --git a/src/libcamera/include/message.h b/src/libcamera/include/message.h\nindex 92717e316cc3..1cfde5669ede 100644\n--- a/src/libcamera/include/message.h\n+++ b/src/libcamera/include/message.h\n@@ -23,6 +23,7 @@ public:\n \tenum Type {\n \t\tNone = 0,\n \t\tInvokeMessage = 1,\n+\t\tThreadMoveMessage = 2,\n \t\tUserMessage = 1000,\n \t};\n \ndiff --git a/src/libcamera/message.cpp b/src/libcamera/message.cpp\nindex f6c39d40fc73..efafb655c17e 100644\n--- a/src/libcamera/message.cpp\n+++ b/src/libcamera/message.cpp\n@@ -47,6 +47,8 @@ std::atomic_uint Message::nextUserType_{ Message::UserMessage };\n  * \\brief Invalid message type\n  * \\var Message::InvokeMessage\n  * \\brief Asynchronous method invocation across threads\n+ * \\var Message::ThreadMoveMessage\n+ * \\brief Object is being moved to a different thread\n  * \\var Message::UserMessage\n  * \\brief First value available for user-defined messages\n  */\ndiff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp\nindex 7d70ce21b5d0..7c68ec01f78c 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -74,6 +74,20 @@ void Object::postMessage(std::unique_ptr<Message> msg)\n \tthread()->postMessage(std::move(msg), this);\n }\n \n+/**\n+ * \\brief Send a message directly to the object\n+ * \\param[in] msg The message\n+ *\n+ * This method sends the message \\a msg directly to the object, delivering it\n+ * synchronously through the message() method in the current thread. Message\n+ * ownership is not passed to the method, and the caller shall delete the\n+ * message after this call.\n+ */\n+void Object::sendMessage(Message *msg)\n+{\n+\tmessage(msg);\n+}\n+\n /**\n  * \\brief Message handler for the object\n  * \\param[in] msg The message\n@@ -135,6 +149,10 @@ void Object::invokeMethod(BoundMethodBase *method, void *args)\n  * This method moves the object from the current thread to the new \\a thread.\n  * It shall be called from the thread in which the object currently lives,\n  * otherwise the behaviour is undefined.\n+ *\n+ * Before the object is moved, a Message::ThreadMoveMessage message is sent to\n+ * it. The message() method can be reimplement in derived classes to be notified\n+ * of the upcoming thread move and perform any required processing.\n  */\n void Object::moveToThread(Thread *thread)\n {\n@@ -143,9 +161,17 @@ void Object::moveToThread(Thread *thread)\n \tif (thread_ == thread)\n \t\treturn;\n \n+\tnotifyThreadMove();\n+\n \tthread->moveObject(this);\n }\n \n+void Object::notifyThreadMove()\n+{\n+\tMessage msg(Message::ThreadMoveMessage);\n+\tsendMessage(&msg);\n+}\n+\n void Object::connect(SignalBase *signal)\n {\n \tsignals_.push_back(signal);\n",
    "prefixes": [
        "libcamera-devel",
        "07/18"
    ]
}