Patch Detail
Show a patch.
GET /api/patches/1829/?format=api
{ "id": 1829, "url": "https://patchwork.libcamera.org/api/patches/1829/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1829/", "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": "<20190817152104.10834-12-laurent.pinchart@ideasonboard.com>", "date": "2019-08-17T15:20:57", "name": "[libcamera-devel,v2,11/18] libcamera: event_notifier: Bind event notifiers to threads", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5eb32fac4e63a16ff10e5994cc7f4ffef6386fa3", "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/1829/mbox/", "series": [ { "id": 463, "url": "https://patchwork.libcamera.org/api/series/463/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=463", "date": "2019-08-17T15:20:46", "name": "Object & Thread enhancements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/463/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1829/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1829/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 EB64361924\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:21:16 +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 881C1F78\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:21:16 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1566055276;\n\tbh=Qe+25sl2Y4H9mML/iy0rFa+dIx2D5ozY+Oxbrah/Ekw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=APOl39tVk1ODL+XvhHXDMwmJcYK6aWQxrdbAFI3JqIfpoyx68QyzNZIhENUAvFR2N\n\txzkNWkLwhsBhtAFDu8fb6cmq3niGrXrYTT3uU9vQCNaxgb8Xxu5NZNvuyUFDVdYdEi\n\tgbvYFYWxTenpyXIKasP3e051/j7L95837DvJySKo=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 17 Aug 2019 18:20:57 +0300", "Message-Id": "<20190817152104.10834-12-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190817152104.10834-1-laurent.pinchart@ideasonboard.com>", "References": "<20190817152104.10834-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 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": "Sat, 17 Aug 2019 15:21:18 -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>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges since v1:\n\n- Fix invokeMethod() call\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..96be27601982 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(&EventNotifier::setEnabled, true);\n+\t\t}\n+\t}\n+\n+\tObject::message(msg);\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v2", "11/18" ] }