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

Naushir Patuck naush at raspberrypi.com
Sun Apr 18 10:58:50 CEST 2021


Hi Laurent,

Thank you for your feedback.

On Fri, 16 Apr 2021 at 17:43, Laurent Pinchart <
laurent.pinchart at ideasonboard.com> wrote:

> 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.
>

Indeed! I'll add the copy and move constructors in the next revision.


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

Fire away :-)

Regards,
Naush


>
> >       template<typename T> T *GetLocked(std::string const &tag)
> >       {
> >               // This allows in-place access to the Metadata contents,
>
> --
> Regards,
>
> Laurent Pinchart
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210418/f62d71f8/attachment.htm>


More information about the libcamera-devel mailing list