[{"id":3861,"web_url":"https://patchwork.libcamera.org/comment/3861/","msgid":"<20200229133326.GH18738@pendragon.ideasonboard.com>","date":"2020-02-29T13:33:26","subject":"Re: [libcamera-devel] [PATCH v2 04/27] gst: utils: Add simple\n\tscoped lockers for GMutex and GRectMutex","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nicolas,\n\nThank you for the patch.\n\nOn Thu, Feb 27, 2020 at 03:03:44PM -0500, Nicolas Dufresne wrote:\n> While GLib has locker implementation already using g_autoptr(), recursive mutext\n\ns/mutext/mutex/\n\n> locker was onmly introduced in recent GLib. Implement a simple locker for GMutex\n\ns/onmly/only/\n\n> and GRectMutex in order to allow making locking simplier and safer.\n\ns/simplier/simpler/\n\n> \n> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> ---\n>  src/gstreamer/gstlibcamera-utils.h | 51 ++++++++++++++++++++++++++++++\n>  1 file changed, 51 insertions(+)\n> \n> diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h\n> index 33160b8..737ca63 100644\n> --- a/src/gstreamer/gstlibcamera-utils.h\n> +++ b/src/gstreamer/gstlibcamera-utils.h\n> @@ -15,4 +15,55 @@\n>  \n>  GstCaps *gst_libcamera_stream_formats_to_caps(const libcamera::StreamFormats &formats);\n>  \n> +/**\n> + * \\class GLibLocker\n> + * \\brief A simple scoped mutex locker for GMutex\n> + */\n> +class GLibLocker\n> +{\n> +public:\n> +\tGLibLocker(GMutex *mutex)\n> +\t\t: mutex_(mutex)\n> +\t{\n> +\t\tg_mutex_lock(mutex_);\n> +\t}\n> +\n> +\tGLibLocker(GstObject *object)\n> +\t\t: mutex_(GST_OBJECT_GET_LOCK(object))\n> +\t{\n> +\t\tg_mutex_lock(mutex_);\n> +\t}\n> +\n> +\t~GLibLocker()\n> +\t{\n> +\t\tg_mutex_unlock(mutex_);\n> +\t}\n> +\n> +private:\n> +\tGMutex *mutex_;\n> +};\n> +\n> +/**\n> + * \\class GLibRecLocker\n> + * \\brief A simple scoped mutex locker for GRecMutex\n> + */\n> +class GLibRecLocker\n> +{\n> +public:\n> +\tGLibRecLocker(GRecMutex *mutex)\n> +\t\t: mutex_(mutex)\n> +\t{\n> +\t\tg_rec_mutex_lock(mutex_);\n> +\t}\n> +\n> +\t~GLibRecLocker()\n> +\t{\n> +\t\tg_rec_mutex_unlock(mutex_);\n> +\t}\n> +\n> +private:\n> +\tGRecMutex *mutex_;\n> +};\n> +\n> +\n\nA single blank line is enough.\n\nWith these small issues fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  #endif /* __GST_LIBCAMERA_UTILS_H_ */","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 245B462689\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 14:33:50 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 851BA2AF;\n\tSat, 29 Feb 2020 14:33:49 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582983229;\n\tbh=IZxm2hSF0DZsKSHvHeuSUU5SvoGo1wR3Vflz/aT6D68=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ab7QMsqA1yGYsN/GwfgQ27HMnae/3VD/wl468R3tG3+I4Oj+J8FXVyBDJzlw++8fs\n\tMbgowv3PYtDycsaAkRSVjjzKWJl1hQbQxvnFpNU0+nkyZBMgl5BHUsYREDxhUz0R/o\n\txGI8VFSDyUF6WOsp65GKojPA78MTl8gkXQVsBFCk=","Date":"Sat, 29 Feb 2020 15:33:26 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200229133326.GH18738@pendragon.ideasonboard.com>","References":"<20200227200407.490616-1-nicolas.dufresne@collabora.com>\n\t<20200227200407.490616-5-nicolas.dufresne@collabora.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200227200407.490616-5-nicolas.dufresne@collabora.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 04/27] gst: utils: Add simple\n\tscoped lockers for GMutex and GRectMutex","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 29 Feb 2020 13:33:50 -0000"}}]