[libcamera-devel] [PATCH v2 2/3] ipa: raspberrypi: Add move operator to RPiController::Metadata

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Apr 16 18:43:18 CEST 2021


Hi Naush,

Thank you for the patch.

On Fri, Apr 16, 2021 at 11:31:40AM +0100, Naushir Patuck wrote:
> Add the move operator implementation for the RPiController::Metadata
> class.
> 
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> ---
>  src/ipa/raspberrypi/controller/metadata.hpp | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp
> index 4f44ffc6771c..c55194040f2f 100644
> --- a/src/ipa/raspberrypi/controller/metadata.hpp
> +++ b/src/ipa/raspberrypi/controller/metadata.hpp
> @@ -45,6 +45,14 @@ public:
>  		data_ = other.data_;
>  		return *this;
>  	}
> +	Metadata &operator=(Metadata &&other)
> +	{
> +		std::lock_guard<std::mutex> lock(mutex_);
> +		std::lock_guard<std::mutex> other_lock(other.mutex_);
> +		data_ = std::move(other.data_);
> +		other.data_.clear();
> +		return *this;
> +	}

https://en.cppreference.com/w/cpp/language/rule_of_three says you should
also implement the copy and move constructors.

I'm a bit concerned by the locks, but that's a separate question.

>  	template<typename T> T *GetLocked(std::string const &tag)
>  	{
>  		// This allows in-place access to the Metadata contents,

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list