Patch Detail
Show a patch.
GET /api/patches/2277/?format=api
{ "id": 2277, "url": "https://patchwork.libcamera.org/api/patches/2277/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2277/", "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": "<20191028104913.14985-5-laurent.pinchart@ideasonboard.com>", "date": "2019-10-28T10:49:08", "name": "[libcamera-devel,v2,4/9] libcamera: bound_method: Support connection types", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "544041db841af9fd71541afd3ddd5390b8dde724", "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/2277/mbox/", "series": [ { "id": 562, "url": "https://patchwork.libcamera.org/api/series/562/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=562", "date": "2019-10-28T10:49:04", "name": "Add support for blocking method invocation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/562/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2277/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2277/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 646F260180\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 11:49:26 +0100 (CET)", "from pendragon.ideasonboard.com (unknown [91.217.168.176])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E1D6325\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 11:49:26 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572259766;\n\tbh=xBRtcyjKiHUhrZ0qK3tIzDsBlecQZet6R3llMvEY5kY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=o9AdMbnFzXguC3hbW3AeN35XyEgO4YBBJDSHSgq0CdFYpZnlIOBWOd2RAKva+nOo+\n\tSvmPbU94bsVpWBNbLZChejdQK5xEQnEcH0eMHMJwJS8Cledubm4U65e1I/VXe5ae3U\n\tG+T0rnzTpmwA2qqbsHAg/0PK0Wagvi+xiTKOe5y4=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 28 Oct 2019 12:49:08 +0200", "Message-Id": "<20191028104913.14985-5-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20191028104913.14985-1-laurent.pinchart@ideasonboard.com>", "References": "<20191028104913.14985-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 4/9] libcamera: bound_method: Support\n\tconnection types", "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": "Mon, 28 Oct 2019 10:49:27 -0000" }, "content": "Support all connection types in the BoundMethodBase::activePack()\nmethod. To support this, add a semaphore to the InvokeMessage to signal\ndelivery.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/bound_method.cpp | 30 ++++++++++++++++++++++++++++--\n src/libcamera/include/message.h | 5 +++++\n src/libcamera/message.cpp | 11 +++++++++--\n src/libcamera/object.cpp | 8 +++++++-\n 4 files changed, 49 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/libcamera/bound_method.cpp b/src/libcamera/bound_method.cpp\nindex ab6ecd9423d1..600717363444 100644\n--- a/src/libcamera/bound_method.cpp\n+++ b/src/libcamera/bound_method.cpp\n@@ -8,6 +8,7 @@\n #include <libcamera/bound_method.h>\n \n #include \"message.h\"\n+#include \"semaphore.h\"\n #include \"thread.h\"\n #include \"utils.h\"\n \n@@ -49,12 +50,37 @@ namespace libcamera {\n \n void BoundMethodBase::activatePack(void *pack)\n {\n-\tif (Thread::current() == object_->thread()) {\n+\tConnectionType type = connectionType_;\n+\tif (type == ConnectionTypeAuto) {\n+\t\tif (Thread::current() == object_->thread())\n+\t\t\ttype = ConnectionTypeDirect;\n+\t\telse\n+\t\t\ttype = ConnectionTypeQueued;\n+\t}\n+\n+\tswitch (type) {\n+\tcase ConnectionTypeDirect:\n+\tdefault:\n \t\tinvokePack(pack);\n-\t} else {\n+\t\tbreak;\n+\n+\tcase ConnectionTypeQueued: {\n \t\tstd::unique_ptr<Message> msg =\n \t\t\tutils::make_unique<InvokeMessage>(this, pack);\n \t\tobject_->postMessage(std::move(msg));\n+\t\tbreak;\n+\t}\n+\n+\tcase ConnectionTypeBlocking: {\n+\t\tSemaphore semaphore;\n+\n+\t\tstd::unique_ptr<Message> msg =\n+\t\t\tutils::make_unique<InvokeMessage>(this, pack, &semaphore);\n+\t\tobject_->postMessage(std::move(msg));\n+\n+\t\tsemaphore.acquire();\n+\t\tbreak;\n+\t}\n \t}\n }\n \ndiff --git a/src/libcamera/include/message.h b/src/libcamera/include/message.h\nindex 1cfde5669ede..311755cc60fe 100644\n--- a/src/libcamera/include/message.h\n+++ b/src/libcamera/include/message.h\n@@ -15,6 +15,7 @@ namespace libcamera {\n \n class BoundMethodBase;\n class Object;\n+class Semaphore;\n class Thread;\n \n class Message\n@@ -48,14 +49,18 @@ class InvokeMessage : public Message\n {\n public:\n \tInvokeMessage(BoundMethodBase *method, void *pack,\n+\t\t Semaphore *semaphore = nullptr,\n \t\t bool deleteMethod = false);\n \t~InvokeMessage();\n \n+\tSemaphore *semaphore() const { return semaphore_; }\n+\n \tvoid invoke();\n \n private:\n \tBoundMethodBase *method_;\n \tvoid *pack_;\n+\tSemaphore *semaphore_;\n \tbool deleteMethod_;\n };\n \ndiff --git a/src/libcamera/message.cpp b/src/libcamera/message.cpp\nindex efafb655c17e..daf653221077 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] semaphore The semaphore used to signal message delivery\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 Semaphore *semaphore, bool deleteMethod)\n \t: Message(Message::InvokeMessage), method_(method), pack_(pack),\n-\t deleteMethod_(deleteMethod)\n+\t semaphore_(semaphore), deleteMethod_(deleteMethod)\n {\n }\n \n@@ -135,6 +136,12 @@ InvokeMessage::~InvokeMessage()\n \t\tdelete method_;\n }\n \n+/**\n+ * \\fn InvokeMessage::semaphore()\n+ * \\brief Retrieve the message semaphore passed to the constructor\n+ * \\return The message semaphore\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 98aa0af2f9b9..b0818f9aa25f 100644\n--- a/src/libcamera/object.cpp\n+++ b/src/libcamera/object.cpp\n@@ -13,6 +13,7 @@\n \n #include \"log.h\"\n #include \"message.h\"\n+#include \"semaphore.h\"\n #include \"thread.h\"\n #include \"utils.h\"\n \n@@ -123,7 +124,12 @@ void Object::message(Message *msg)\n \tswitch (msg->type()) {\n \tcase Message::InvokeMessage: {\n \t\tInvokeMessage *iMsg = static_cast<InvokeMessage *>(msg);\n+\t\tSemaphore *semaphore = iMsg->semaphore();\n \t\tiMsg->invoke();\n+\n+\t\tif (semaphore)\n+\t\t\tsemaphore->release();\n+\n \t\tbreak;\n \t}\n \n@@ -150,7 +156,7 @@ void Object::message(Message *msg)\n void Object::invokeMethod(BoundMethodBase *method, void *args)\n {\n \tstd::unique_ptr<Message> msg =\n-\t\tutils::make_unique<InvokeMessage>(method, args, true);\n+\t\tutils::make_unique<InvokeMessage>(method, args, nullptr, true);\n \tpostMessage(std::move(msg));\n }\n \n", "prefixes": [ "libcamera-devel", "v2", "4/9" ] }