[libcamera-devel] [PATCH v2 02/18] libcamera: thread: Wake up target thread when moving objects

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Aug 17 17:20:48 CEST 2019


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 <laurent.pinchart at ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 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<Message> &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();
 		}
 	}
 
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list