Show a patch.

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

{
    "id": 2235,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2235/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2235/",
    "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": "<20191027203335.26888-5-jacopo@jmondi.org>",
    "date": "2019-10-27T20:33:33",
    "name": "[libcamera-devel,4/6] libcamera: Support blocking method invocation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "52ddd6a5924bbd13dabedcfea5de38740b8e6dda",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/2235/mbox/",
    "series": [
        {
            "id": 558,
            "url": "https://patchwork.libcamera.org/api/1.1/series/558/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=558",
            "date": "2019-10-27T20:33:29",
            "name": "Add support for blocking method invocation",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/558/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2235/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2235/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EC1F46017A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Oct 2019 21:31:49 +0100 (CET)",
            "from uno.localdomain (143.121.2.93.rev.sfr.net [93.2.121.143])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A4438C0002;\n\tSun, 27 Oct 2019 20:31:49 +0000 (UTC)"
        ],
        "X-Originating-IP": "93.2.121.143",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 27 Oct 2019 21:33:33 +0100",
        "Message-Id": "<20191027203335.26888-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20191027203335.26888-1-jacopo@jmondi.org>",
        "References": "<20191027203335.26888-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 4/6] libcamera: Support blocking method\n\tinvocation",
        "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>",
        "X-List-Received-Date": "Sun, 27 Oct 2019 20:31:51 -0000"
    },
    "content": "Add support for blocking method invocation by providing a conditional\nvariable to the InvokeMessage class operation and have the\nObject::invokeMethod() caller operation to wait on the conditional\nvariable if the message invocationType is InvocationTypeBlocking.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/message.h |  5 +++++\n src/libcamera/message.cpp       | 11 +++++++++--\n src/libcamera/object.cpp        | 14 +++++++++++++-\n 3 files changed, 27 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/message.h b/src/libcamera/include/message.h\nindex 1cfde5669ede..cfb674adbccb 100644\n--- a/src/libcamera/include/message.h\n+++ b/src/libcamera/include/message.h\n@@ -10,6 +10,7 @@\n #include <atomic>\n \n #include <libcamera/bound_method.h>\n+#include <libcamera/object.h>\n \n namespace libcamera {\n \n@@ -48,14 +49,18 @@ class InvokeMessage : public Message\n {\n public:\n \tInvokeMessage(BoundMethodBase *method, void *pack,\n+\t\t      ObjectConditionVariable *cond = nullptr,\n \t\t      bool deleteMethod = false);\n \t~InvokeMessage();\n \n+\tObjectConditionVariable *cond() const { return cond_; }\n+\n \tvoid invoke();\n \n private:\n \tBoundMethodBase *method_;\n \tvoid *pack_;\n+\tObjectConditionVariable *cond_;\n \tbool deleteMethod_;\n };\n \ndiff --git a/src/libcamera/message.cpp b/src/libcamera/message.cpp\nindex efafb655c17e..865404e81cfb 100644\n--- a/src/libcamera/message.cpp\n+++ b/src/libcamera/message.cpp\n@@ -119,13 +119,14 @@ Message::Type Message::registerMessageType()\n  * \\brief Construct an InvokeMessage for method invocation on an Object\n  * \\param[in] method The bound method\n  * \\param[in] pack The packed method arguments\n+ * \\param[in] cond The condition variable used to signal reception of the message\n  * \\param[in] deleteMethod True to delete the \\a method when the message is\n  * destroyed\n  */\n InvokeMessage::InvokeMessage(BoundMethodBase *method, void *pack,\n-\t\t\t     bool deleteMethod)\n+\t\t\t     ObjectConditionVariable *cond, bool deleteMethod)\n \t: Message(Message::InvokeMessage), method_(method), pack_(pack),\n-\t  deleteMethod_(deleteMethod)\n+\t  cond_(cond), deleteMethod_(deleteMethod)\n {\n }\n \n@@ -135,6 +136,12 @@ InvokeMessage::~InvokeMessage()\n \t\tdelete method_;\n }\n \n+/**\n+ * \\fn InvokeMessage::cond()\n+ * \\brief Retrieve the synchronization condition variable\n+ * \\return The ObjectConditionVariable\n+ */\n+\n /**\n  * \\brief Invoke the method bound to InvokeMessage::method_ with arguments\n  * InvokeMessage::pack_\ndiff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp\nindex 88054aba3454..ee6f5efc984c 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -196,7 +196,12 @@ void Object::message(Message *msg)\n \tswitch (msg->type()) {\n \tcase Message::InvokeMessage: {\n \t\tInvokeMessage *iMsg = static_cast<InvokeMessage *>(msg);\n+\t\tObjectConditionVariable *cond = iMsg->cond();\n \t\tiMsg->invoke();\n+\n+\t\tif (cond)\n+\t\t\tcond->notifyReception();\n+\n \t\tbreak;\n \t}\n \n@@ -223,9 +228,16 @@ void Object::message(Message *msg)\n \n void Object::invokeMethod(BoundMethodBase *method, InvocationType type, void *args)\n {\n+\tObjectConditionVariable cond;\n+\tObjectConditionVariable *c = type == InvocationTypeBlocking ?\n+\t\t\t\t     &cond : nullptr;\n+\n \tstd::unique_ptr<Message> msg =\n-\t\tutils::make_unique<InvokeMessage>(method, args, true);\n+\t\tutils::make_unique<InvokeMessage>(method, args, c, true);\n \tpostMessage(std::move(msg));\n+\n+\tif (c)\n+\t\tc->waitDelivery();\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "4/6"
    ]
}