summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-12 04:29:08 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-17 18:32:26 +0300
commit391b184fc57ddcfdf38d3fd3a32b9acc5e7cc4e0 (patch)
tree81f00b2d2fe9d28771196d8542c86ec09ffe42e7 /src
parentf0ba6ab2a80a649b7fc7d607146c61a22db019ff (diff)
libcamera: thread: Wake up target thread when moving objects
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@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/thread.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp
index 5d46eeb8..6f86e4a9 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();
}
}