From patchwork Fri Aug 19 11:16:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 17180 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1DB78C327E for ; Fri, 19 Aug 2022 11:16:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BEBA361FC9; Fri, 19 Aug 2022 13:16:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660907797; bh=8NLR0FxcULLStTI51TfPY5LofhxaBSG9bWYCSh60mxc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=C03zgG9KIwsB6PcrJ/OrGrVJvWhPnwb6TQd9MYJBzB2FxMwWvoLBrKi2+UZJlC+gE BrV4md3392Vu1eV55xaSXDE8k1IUiabKDQtd8yS5HemZtxiSjS83CySlUNnsvyuWVu LWzpZxO2R+sGim/GKShxQ+hKMK/vmftiDT5MlZuvoJb0vo3irptEwRYNPuZDhve8Fk oYvUFQnrTxKTwtb8B/aSXosiLMgQkmmFnL3uS5tNsf3UJkUF/JZwUhch6/1BtgGxIa DbiQr6lh7sfCFG1ldC4gk/T9g/KTC2Xlkkqznw+eFRDm0GnJ00klZcpE0wYRz1zcao rznJwZixWufqg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C898A61FA4 for ; Fri, 19 Aug 2022 13:16:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SPUPGSg8"; dkim-atps=neutral Received: from deskari.lan (91-158-154-79.elisa-laajakaista.fi [91.158.154.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E4C7576; Fri, 19 Aug 2022 13:16:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1660907792; bh=8NLR0FxcULLStTI51TfPY5LofhxaBSG9bWYCSh60mxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPUPGSg8msC0/IN65vNbKEHwRe5JrxiWNCryTcjHT2J0x9Plj5p0JmocMp7y7l+RA LON6X6p8Ndm7X3imeo2EgT2j7xAmTRtWqPUaWEaGIF84JJswuRoGXbtGvI3npnSLd3 QS0LeJ1pJ1zoSLXNTcx0rZw+K3RToqaxtPO2hkaA= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Fri, 19 Aug 2022 14:16:14 +0300 Message-Id: <20220819111615.39814-6-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819111615.39814-1-tomi.valkeinen@ideasonboard.com> References: <20220819111615.39814-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 5/6] py: Use libcamera's Mutex classes X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use libcamera's Mutex and MutexLocker instead of the std versions to get thread safety annotations. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- src/py/libcamera/py_camera_manager.cpp | 4 ++-- src/py/libcamera/py_camera_manager.h | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/py/libcamera/py_camera_manager.cpp b/src/py/libcamera/py_camera_manager.cpp index 8bfb8e57..ea4ae825 100644 --- a/src/py/libcamera/py_camera_manager.cpp +++ b/src/py/libcamera/py_camera_manager.cpp @@ -106,14 +106,14 @@ void PyCameraManager::readFd() void PyCameraManager::pushRequest(Request *req) { - std::lock_guard guard(completedRequestsMutex_); + MutexLocker guard(completedRequestsMutex_); completedRequests_.push_back(req); } std::vector PyCameraManager::getCompletedRequests() { std::vector v; - std::lock_guard guard(completedRequestsMutex_); + MutexLocker guard(completedRequestsMutex_); swap(v, completedRequests_); return v; } diff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h index 710163e8..56bea13d 100644 --- a/src/py/libcamera/py_camera_manager.h +++ b/src/py/libcamera/py_camera_manager.h @@ -5,7 +5,7 @@ #pragma once -#include +#include #include @@ -34,8 +34,9 @@ private: std::unique_ptr cameraManager_; UniqueFD eventFd_; - std::mutex completedRequestsMutex_; - std::vector completedRequests_; + libcamera::Mutex completedRequestsMutex_; + std::vector completedRequests_ + LIBCAMERA_TSA_GUARDED_BY(completedRequestsMutex_); void writeFd(); void readFd();