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

Niklas Söderlund niklas.soderlund at ragnatech.se
Sat Aug 17 16:07:28 CEST 2019


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 at ideasonboard.com>

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
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list