Message ID | 20190812124642.24287-3-laurent.pinchart@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your work. On 2019-08-12 15:46:26 +0300, Laurent Pinchart wrote: > 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: Niklas Söderlund <niklas.soderlund@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 > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
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(); } }
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> --- src/libcamera/thread.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+)