From patchwork Sat Aug 17 15:20:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1820 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9009600F9 for ; Sat, 17 Aug 2019 17:21:13 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F82C556 for ; Sat, 17 Aug 2019 17:21:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566055273; bh=fpsYxOAjB6Uptc5Ip+nhbWmh7mpTj04m3sT/Bvl+Q+k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jhhT4jIbW3g3hfPtuuvK9yj7mzDPezIxcIsGICTOB90vJZ+VBwPzdQ2hl8LfU2cWw SD3KdVq98WbfzyJ48I1icKrEz7sqvhaDpj0q8GtrJuzl1/OfmrR30IvBAO9R7prq7m FD84Q12wPFMJ9TxiWlWCtnNSLJbCg0Mg+iEVWW+s= From: Laurent Pinchart 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 Subject: [libcamera-devel] [PATCH v2 02/18] libcamera: thread: Wake up target thread when moving objects X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Aug 2019 15:21:13 -0000 When moving an object to a different thread, messages posted for the object are moved to the message queue of the new thread. Wake up the new thread to ensure it processes the moved messages. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/thread.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp index 5d46eeb8d3a5..6f86e4a90a05 100644 --- a/src/libcamera/thread.cpp +++ b/src/libcamera/thread.cpp @@ -464,6 +464,8 @@ void Thread::moveObject(Object *object) /* Move pending messages to the message queue of the new thread. */ if (object->pendingMessages_) { + unsigned int movedMessages = 0; + for (std::unique_ptr &msg : currentData->messages_.list_) { if (!msg) continue; @@ -471,6 +473,14 @@ void Thread::moveObject(Object *object) continue; targetData->messages_.list_.push_back(std::move(msg)); + movedMessages++; + } + + if (movedMessages) { + EventDispatcher *dispatcher = + targetData->dispatcher_.load(std::memory_order_acquire); + if (dispatcher) + dispatcher->interrupt(); } }