From patchwork Fri Dec 3 16:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 15018 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 685A7BF415 for ; Fri, 3 Dec 2021 16:46:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15B7760832; Fri, 3 Dec 2021 17:46:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JwDVWpJj"; dkim-atps=neutral Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B30060832 for ; Fri, 3 Dec 2021 17:46:35 +0100 (CET) Received: by mail-pj1-x1034.google.com with SMTP id k6-20020a17090a7f0600b001ad9d73b20bso654396pjl.3 for ; Fri, 03 Dec 2021 08:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aaXWYeJ3wIyj4arkroVtv0cJnoJqlHwOboUzeCUjESo=; b=JwDVWpJjpbQNdHR8Z1n6g3bj8Zd/+wdklPbFvdfuYliBLy6Qzvo/Ixb6JgHgOCynAX HYFVRGo16hCmyNgmpiv4pk4KPCRYx+g6h+soJeQt6VopsMwLgalhDOCsjdvtebOj3kht dKVuGfIw1GX75qw3ZPUz7r+6hdCfjy9vgD3PU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aaXWYeJ3wIyj4arkroVtv0cJnoJqlHwOboUzeCUjESo=; b=k1cP0cJ+d5gS5BChGCDLcmEiFJlwAWYOm1BPVahPlc0oQYx/shN7p0eyRaVIbyO9gD UZU0zyPiZ1aSd3+4xeVECXfaa4RHdt9rTV3PrPbEOC30EVGrht+QT/LyFYzA8z8Xjj9y SZW4eXQG9n94H/pCARb5nzw6/dt+rbcmgxKDnmR22kWK0AJVSAN6iCjJ1x8qLFHh92K9 TW3OSQc0TzEk1Lmz4OoK501O/Q5fS1A3a8hbY7u9k2eF3YhwiJlPGO6h2YUuaPyIJ/zI g2PcmWrMwHPviNISFP3nlTvjYaohBi/zZkgSUJch14vj5FmPcOKXy6ztmOUYQVIllQKo +6cA== X-Gm-Message-State: AOAM533MJ8gV+O1cdTbs3AdpFFHIHXN6TjTyd93NkyuRC64stXoJuFuI r6F3yg4gS8Rhd3iZOdnjd+uQGgi8Gd/FNw== X-Google-Smtp-Source: ABdhPJwhYrWB0OnZbPCZQH3TwxJV0arqHtzCyWxG2SgBdlqpIJqjnx8elBD3vYVt9ySWBouNrkN7Hw== X-Received: by 2002:a17:90a:1913:: with SMTP id 19mr15350770pjg.174.1638549993474; Fri, 03 Dec 2021 08:46:33 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:cd78:3a5f:d792:6177]) by smtp.gmail.com with ESMTPSA id h18sm4123149pfh.172.2021.12.03.08.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 08:46:33 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Dec 2021 01:46:17 +0900 Message-Id: <20211203164619.1541033-6-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.384.gca35af8252-goog In-Reply-To: <20211203164619.1541033-1-hiroh@chromium.org> References: <20211203164619.1541033-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/7] 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This annotates member functions and variables of CameraManager::Private by clang thread safety annotations. Signed-off-by: Hirokazu Honda --- 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 4492edc3..507f68f5 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_; }