{"id":1780,"url":"https://patchwork.libcamera.org/api/patches/1780/?format=json","web_url":"https://patchwork.libcamera.org/patch/1780/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","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-3-laurent.pinchart@ideasonboard.com>","date":"2019-08-12T12:46:26","name":"[libcamera-devel,02/18] libcamera: thread: Wake up target thread when moving objects","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2a8e7e33b40d271aa99340f3c82f853febea2c6f","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1780/mbox/","series":[{"id":455,"url":"https://patchwork.libcamera.org/api/series/455/?format=json","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/1780/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1780/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 80EA760E38\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2019 14:46:49 +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 22C62327\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2019 14:46:49 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1565614009;\n\tbh=Pkpe1AGRDZvfElHXqq10DdD+hhUbrz6k0xRC16ZrQRw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=q4h8d3hcoGYWHN69XwAzoEs86Q//au0VMWyG73zbaPOrBOMGqRh81/GfdwxBCAmey\n\tBmFN6e5PYDz4hDbm0EUSNiCHrDDy5O6u/WvKYto+ks71EJnDv39YZmg1i5+3v+28aT\n\tctsvUHKWFmHyVA0k1T/yrHbWt4OBjHF0MEcn0dPw=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 12 Aug 2019 15:46:26 +0300","Message-Id":"<20190812124642.24287-3-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 02/18] libcamera: thread: Wake up target\n\tthread when moving objects","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:49 -0000"},"content":"When moving an object to a different thread, messages posted for the\nobject are moved to the message queue of the new thread. Wake up the new\nthread to ensure it processes the moved messages.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/thread.cpp | 10 ++++++++++\n 1 file changed, 10 insertions(+)","diff":"diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\nindex 5d46eeb8d3a5..6f86e4a90a05 100644\n--- a/src/libcamera/thread.cpp\n+++ b/src/libcamera/thread.cpp\n@@ -464,6 +464,8 @@ void Thread::moveObject(Object *object)\n \n \t/* Move pending messages to the message queue of the new thread. */\n \tif (object->pendingMessages_) {\n+\t\tunsigned int movedMessages = 0;\n+\n \t\tfor (std::unique_ptr<Message> &msg : currentData->messages_.list_) {\n \t\t\tif (!msg)\n \t\t\t\tcontinue;\n@@ -471,6 +473,14 @@ void Thread::moveObject(Object *object)\n \t\t\t\tcontinue;\n \n \t\t\ttargetData->messages_.list_.push_back(std::move(msg));\n+\t\t\tmovedMessages++;\n+\t\t}\n+\n+\t\tif (movedMessages) {\n+\t\t\tEventDispatcher *dispatcher =\n+\t\t\t\ttargetData->dispatcher_.load(std::memory_order_acquire);\n+\t\t\tif (dispatcher)\n+\t\t\t\tdispatcher->interrupt();\n \t\t}\n \t}\n \n","prefixes":["libcamera-devel","02/18"]}