Patch Detail
Show a patch.
GET /api/1.1/patches/1789/?format=api
{ "id": 1789, "url": "https://patchwork.libcamera.org/api/1.1/patches/1789/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1789/", "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": "<20190812124642.24287-12-laurent.pinchart@ideasonboard.com>", "date": "2019-08-12T12:46:35", "name": "[libcamera-devel,11/18] libcamera: event_notifier: Bind event notifiers to threads", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "edcffd2a0f86d5204b62e87254e9d4f090fac78a", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1789/mbox/", "series": [ { "id": 455, "url": "https://patchwork.libcamera.org/api/1.1/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/1789/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1789/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 2A3396194E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2019 14:46:53 +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 AD236133B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2019 14:46:52 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1565614012;\n\tbh=yCQTUfaNdbhyLf+PSvrMPNrHxp/XsLuLe8mKG+u8mG4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=t/s2fZcUXH03MW4BnYpHeuo78JvC+Cug8/XQpB/Yc6dqx89xKoVmewV0liPdTt7tl\n\tEchIu1QwXoI8Qx2OcBYupGnXkEkA5M0XX3KOJS9AhCOHd26D/EbcSO6v5GFxhxWRBr\n\tz38wAwECpMXhcOyd1S7iYASqRv4bAkhAluJBG5/U=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 12 Aug 2019 15:46:35 +0300", "Message-Id": "<20190812124642.24287-12-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 11/18] libcamera: event_notifier: Bind\n\tevent notifiers to threads", "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": "The EventNotifier instances are registered with the event dispatcher\ninstance of the CameraManager. This makes it impossible to use event\nnotifiers in other threads.\n\nFix this by inheriting from Object, which allows binding instances to a\nthread, and register them with the event dispatcher for the thread they\nare bound to.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/event_notifier.h | 8 +++++++-\n src/libcamera/event_notifier.cpp | 17 ++++++++++++++++-\n 2 files changed, 23 insertions(+), 2 deletions(-)", "diff": "diff --git a/include/libcamera/event_notifier.h b/include/libcamera/event_notifier.h\nindex 1e9b6da1340c..f80945c743dc 100644\n--- a/include/libcamera/event_notifier.h\n+++ b/include/libcamera/event_notifier.h\n@@ -7,11 +7,14 @@\n #ifndef __LIBCAMERA_EVENT_NOTIFIER_H__\n #define __LIBCAMERA_EVENT_NOTIFIER_H__\n \n+#include <libcamera/object.h>\n #include <libcamera/signal.h>\n \n namespace libcamera {\n \n-class EventNotifier\n+class Message;\n+\n+class EventNotifier : public Object\n {\n public:\n \tenum Type {\n@@ -31,6 +34,9 @@ public:\n \n \tSignal<EventNotifier *> activated;\n \n+protected:\n+\tvoid message(Message *msg) override;\n+\n private:\n \tint fd_;\n \tType type_;\ndiff --git a/src/libcamera/event_notifier.cpp b/src/libcamera/event_notifier.cpp\nindex b32c7ed2d315..515e6d1770a1 100644\n--- a/src/libcamera/event_notifier.cpp\n+++ b/src/libcamera/event_notifier.cpp\n@@ -10,6 +10,9 @@\n #include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n \n+#include \"message.h\"\n+#include \"thread.h\"\n+\n /**\n * \\file event_notifier.h\n * \\brief File descriptor event notifier\n@@ -103,7 +106,7 @@ void EventNotifier::setEnabled(bool enable)\n \n \tenabled_ = enable;\n \n-\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\tEventDispatcher *dispatcher = thread()->eventDispatcher();\n \tif (enable)\n \t\tdispatcher->registerEventNotifier(this);\n \telse\n@@ -119,4 +122,16 @@ void EventNotifier::setEnabled(bool enable)\n * parameter.\n */\n \n+void EventNotifier::message(Message *msg)\n+{\n+\tif (msg->type() == Message::ThreadMoveMessage) {\n+\t\tif (enabled_) {\n+\t\t\tsetEnabled(false);\n+\t\t\tinvokeMethod(this, &EventNotifier::setEnabled, true);\n+\t\t}\n+\t}\n+\n+\tObject::message(msg);\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "11/18" ] }