From patchwork Fri Jul 1 08:45:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16500 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 82DFEBD808 for ; Fri, 1 Jul 2022 08:45:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96EF7656A2; Fri, 1 Jul 2022 10:45:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656665151; bh=P4csJrs78yKiXsTsTozO9b8oqqTGp+igSSWlBlKQZyo=; 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=2/vUu7/DC0dhRkaIqLBHftWYN4YhKCy+vB5rUbdDVUcKZLb1Rt0FQBog2ShAZBRH5 qRYJXq0mS+wtfdQaIA9mEkrECxhm9sGkqJ4vIgopCKXMm/khx8vG7z2Q6mSS5t6MGv JyiS6kcV8ql3z4+ooatG0/crQmCA5y8oo65Lke6gQ0UyvFHlfPlp88AcJnSb1F31sn wnCHwchtll3Sq6GExTC1F0l8nZvFpVzyE6cCuyz9K/97ngTnEokjHPDRK8RFimV1eC LooZSw9aXwDcxjHdk0c2wq7yyOczh4baZ+ssjC05SJP21R/2mmF5XVLPkO85ZZTOSr h6yMT6Yk7hykg== 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 706146565A for ; Fri, 1 Jul 2022 10:45:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="E8M8d94Y"; 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 E93C46BB; Fri, 1 Jul 2022 10:45:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1656665144; bh=P4csJrs78yKiXsTsTozO9b8oqqTGp+igSSWlBlKQZyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8M8d94Y67VIBIDmTdeXp8JqrhS8qibWJZTqUODEDjLHDGg/gs67R7d0hUYpAbY9F gLCQqBzdHwNwb+838+HoMf5cDN+LHg5HXD6WqU3N6oEMFf1AZ2hrRTAzktAudyGG4j BUxW9LHcLVx7oLbTDH3p8OMXUgWWz+drRnvBxyX8= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Fri, 1 Jul 2022 11:45:12 +0300 Message-Id: <20220701084521.31831-9-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220701084521.31831-1-tomi.valkeinen@ideasonboard.com> References: <20220701084521.31831-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 08/17] 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 3d422c9e..5600f661 100644 --- a/src/py/libcamera/py_camera_manager.cpp +++ b/src/py/libcamera/py_camera_manager.cpp @@ -104,14 +104,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();