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>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user