From patchwork Mon Jun 20 16:50:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16290 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 9E7BBBE173 for ; Mon, 20 Jun 2022 16:50:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C7606563E; Mon, 20 Jun 2022 18:50:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655743845; bh=T6yGjc+PySgh/1/kxCKfvN3M0leBsGQPLp/OacR3Tl0=; 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=YUfjgUwKxf1NefJWkw4N0Myy+WY2w2X4FFoP0OQ1ITNY8deUBTPj0u/7LiltjnaS5 qJ0J+uB+G33YgMG0wXBerESxjwRBg1UltEfLMfIMnzSv0v0/+BPU5BoR5KeMmUZy9H PZx4F0s0WQwhEDXuqpKUTnKi4H3QK1FmRvO8PxXKrwhwN3AHEVTyqQ6LnGriVa613o CN6neUCe2Rjfkf09Xl+W6HiQovbHjRsA9idjI8NDQxYx1fvd6m2rtAixehlIWo6r1B qCqVeq3dDRUPdlvZcOwn5RSHF1Vm+57IxWC6mFoGw4vQaZbwtLLVg9tsfF7bjXFCK1 ssP+xOUmPbh+Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D9E4865637 for ; Mon, 20 Jun 2022 18:50:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="I9MuwbmP"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:e389:cb58:4104:f66:a571]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 46A09883; Mon, 20 Jun 2022 18:50:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655743843; bh=T6yGjc+PySgh/1/kxCKfvN3M0leBsGQPLp/OacR3Tl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9MuwbmPGzOf1EBfzF3WEzeOx0m0fjtTbpNczCrgDp/XInluVAJuPkimCScl6ZujZ AloZ1E9FQJgmc/t4pJrO7xgAy9wERsitiwHT9QT63N75Vld78VNI4PD8ovEKtdV58+ 99nR4mwdD5c8BzoEFbbC3G6E3+gaQHscF050Qp90= To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jun 2022 22:20:25 +0530 Message-Id: <20220620165027.549085-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220620165027.549085-1-umang.jain@ideasonboard.com> References: <20220620165027.549085-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] libcamera: camera_manager: Apply clang thread safety annotation 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hirokazu Honda This annotates member functions and variables of CameraManager::Private by clang thread safety annotations. Signed-off-by: Hirokazu Honda Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/libcamera/camera_manager.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 70d73822..4f946516 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -42,8 +42,8 @@ public: int start(); void addCamera(std::shared_ptr camera, - const std::vector &devnums); - void removeCamera(Camera *camera); + const std::vector &devnums) LIBCAMERA_TSA_EXCLUDES(mutex_); + void removeCamera(Camera *camera) LIBCAMERA_TSA_EXCLUDES(mutex_); /* * This mutex protects @@ -52,8 +52,8 @@ public: * - cameras_ and camerasByDevnum_ after initialization */ mutable Mutex mutex_; - std::vector> cameras_; - std::map> camerasByDevnum_; + std::vector> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + std::map> camerasByDevnum_ LIBCAMERA_TSA_GUARDED_BY(mutex_); protected: void run() override; @@ -61,11 +61,11 @@ protected: private: int init(); void createPipelineHandlers(); - void cleanup(); + void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_); ConditionVariable cv_; - bool initialized_; - int status_; + bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_); std::unique_ptr enumerator_; @@ -87,7 +87,8 @@ int CameraManager::Private::start() { MutexLocker locker(mutex_); - cv_.wait(locker, [&] { return initialized_; }); + cv_.wait(locker, + [&]() LIBCAMERA_TSA_REQUIRES(mutex_) { return initialized_; }); status = status_; }