{"id":1820,"url":"https://patchwork.libcamera.org/api/patches/1820/?format=json","web_url":"https://patchwork.libcamera.org/patch/1820/","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":"<20190817152104.10834-3-laurent.pinchart@ideasonboard.com>","date":"2019-08-17T15:20:48","name":"[libcamera-devel,v2,02/18] libcamera: thread: Wake up target thread when moving objects","commit_ref":null,"pull_url":null,"state":"accepted","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/1820/mbox/","series":[{"id":463,"url":"https://patchwork.libcamera.org/api/series/463/?format=json","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/1820/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1820/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 A9009600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:21:13 +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 4F82C556\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:21:13 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1566055273;\n\tbh=fpsYxOAjB6Uptc5Ip+nhbWmh7mpTj04m3sT/Bvl+Q+k=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=jhhT4jIbW3g3hfPtuuvK9yj7mzDPezIxcIsGICTOB90vJZ+VBwPzdQ2hl8LfU2cWw\n\tSD3KdVq98WbfzyJ48I1icKrEz7sqvhaDpj0q8GtrJuzl1/OfmrR30IvBAO9R7prq7m\n\tFD84Q12wPFMJ9TxiWlWCtnNSLJbCg0Mg+iEVWW+s=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 17 Aug 2019 18:20:48 +0300","Message-Id":"<20190817152104.10834-3-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 02/18] libcamera: thread: Wake up\n\ttarget thread 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":"Sat, 17 Aug 2019 15:21:13 -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>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\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","v2","02/18"]}