{"id":14941,"url":"https://patchwork.libcamera.org/api/1.1/patches/14941/?format=json","web_url":"https://patchwork.libcamera.org/patch/14941/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211201075348.3121186-2-hiroh@chromium.org>","date":"2021-12-01T07:53:37","name":"[libcamera-devel,v5,01/12] libcamera: base: Introduce ConditionVariable","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"07196e708571922015eab0544c114f52e57bac4f","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14941/mbox/","series":[{"id":2791,"url":"https://patchwork.libcamera.org/api/1.1/series/2791/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2791","date":"2021-12-01T07:53:36","name":"Introduce clang thread safety annotations","version":5,"mbox":"https://patchwork.libcamera.org/series/2791/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14941/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14941/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 604EFBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 07:53:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E6F460718;\n\tWed,  1 Dec 2021 08:53:59 +0100 (CET)","from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com\n\t[IPv6:2607:f8b0:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C286460723\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 08:53:57 +0100 (CET)","by mail-pf1-x42c.google.com with SMTP id n85so23507344pfd.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:53:57 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3892:a049:59ba:c772])\n\tby smtp.gmail.com with ESMTPSA id\n\tl9sm3500848pfu.55.2021.11.30.23.53.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:53:55 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"JyjcwSYz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=RfQVNtG/v2bEcPhs3B2DWL5RmPs7AC4Gxpfmf3NMFrs=;\n\tb=JyjcwSYzD38HqNjvbFMNMYF3FaDfjicow+so1nvqGCqSNfvVsB6G9oSaDWMjvtut6T\n\tyzRtSVAfHpywukN66RIyvjtMfXu0gR0tDeEPCmmwxM8NZ1BCdNrNS9ZLtYhmAbQhcbzN\n\txFS6Q7jx/h94Hk9knxNlEThpiZIDMbsdd3e4s=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=RfQVNtG/v2bEcPhs3B2DWL5RmPs7AC4Gxpfmf3NMFrs=;\n\tb=qsZVBbhulFiTpMsleidF0I9wEinD0fzkIb58uZFA6nSO5OABrbxfCVvJUGnxw5iEie\n\tj2eQ42AVwQYybMDyK2CvWoVGD/sd+mu2UcFztoWXVOL2x3ec1rdQE1Yl0L4ubINNuM3B\n\tBUveAxLtN/IvV4yO0aig2Te0I7PnpEf5lL/jooe62rNv1lOp9sTi+b+jWsl2kLDHBj51\n\tM3gaRhlmpf8Bz+JTzJvJb8l2JolowMv1yNfaNOIZv6M5WQ3fIYnJwpTUwbQJgwwXHK6y\n\tEKcIH1qgi0g4B7jPqiXm+1bfRhJOzVCOAcSSCP3o8ypixIIV8oAluGr6fiqIq2boACH5\n\tF+MQ==","X-Gm-Message-State":"AOAM533+XaY3Y4/qAZE0/8pf4xhRxzt2FaXmrlSPWTAk/tqDq5KNbVdF\n\tiTPqxLQ2UTYkWj/HPqX1qx0ZDKqIlN7ZOA==","X-Google-Smtp-Source":"ABdhPJy3+fLDXV/ZbUeibs52I82ZGI5yb1Im2YGtqghxbWE5eWDSvGVQBduLApxUut9gmikNJWP/6g==","X-Received":"by 2002:aa7:804b:0:b0:4a4:b2e2:e046 with SMTP id\n\ty11-20020aa7804b000000b004a4b2e2e046mr4492014pfm.81.1638345236158; \n\tTue, 30 Nov 2021 23:53:56 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  1 Dec 2021 16:53:37 +0900","Message-Id":"<20211201075348.3121186-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc2.393.gf8c9666880-goog","In-Reply-To":"<20211201075348.3121186-1-hiroh@chromium.org>","References":"<20211201075348.3121186-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 01/12] libcamera: base: Introduce\n\tConditionVariable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"ConditionVariable is alias to std::condition_variable. This replaces\nstd::condition_variable with the ConditionVariable. It enables\nreplacing ConditionVariable implementation easily in the following\npatches.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/semaphore.h | 4 +---\n include/libcamera/base/thread.h    | 2 ++\n src/android/camera_stream.h        | 3 +--\n src/libcamera/base/thread.cpp      | 8 ++++++--\n src/libcamera/camera_manager.cpp   | 3 +--\n src/v4l2/v4l2_camera.h             | 2 +-\n 6 files changed, 12 insertions(+), 10 deletions(-)","diff":"diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h\nindex ae87d319..ec05fad3 100644\n--- a/include/libcamera/base/semaphore.h\n+++ b/include/libcamera/base/semaphore.h\n@@ -7,8 +7,6 @@\n \n #pragma once\n \n-#include <condition_variable>\n-\n #include <libcamera/base/private.h>\n #include <libcamera/base/thread.h>\n \n@@ -26,7 +24,7 @@ public:\n \n private:\n \tMutex mutex_;\n-\tstd::condition_variable cv_;\n+\tConditionVariable cv_;\n \tunsigned int available_;\n };\n \ndiff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h\nindex 32ebc80a..1ebf8363 100644\n--- a/include/libcamera/base/thread.h\n+++ b/include/libcamera/base/thread.h\n@@ -7,6 +7,7 @@\n \n #pragma once\n \n+#include <condition_variable>\n #include <memory>\n #include <mutex>\n #include <sys/types.h>\n@@ -26,6 +27,7 @@ class Object;\n class ThreadData;\n class ThreadMain;\n \n+using ConditionVariable = std::condition_variable;\n using Mutex = std::mutex;\n using MutexLocker = std::unique_lock<std::mutex>;\n \ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex e9da75f0..e4808369 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -7,7 +7,6 @@\n \n #pragma once\n \n-#include <condition_variable>\n #include <memory>\n #include <mutex>\n #include <queue>\n@@ -154,7 +153,7 @@ private:\n \t\tPostProcessor *postProcessor_;\n \n \t\tlibcamera::Mutex mutex_;\n-\t\tstd::condition_variable cv_;\n+\t\tlibcamera::ConditionVariable cv_;\n \n \t\tstd::queue<Camera3RequestDescriptor::StreamBuffer *> requests_;\n \t\tState state_ = State::Stopped;\ndiff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp\nindex d0ca30e3..b893135f 100644\n--- a/src/libcamera/base/thread.cpp\n+++ b/src/libcamera/base/thread.cpp\n@@ -8,7 +8,6 @@\n #include <libcamera/base/thread.h>\n \n #include <atomic>\n-#include <condition_variable>\n #include <list>\n #include <sys/syscall.h>\n #include <sys/types.h>\n@@ -158,7 +157,7 @@ private:\n \n \tstd::atomic<EventDispatcher *> dispatcher_;\n \n-\tstd::condition_variable cv_;\n+\tConditionVariable cv_;\n \tstd::atomic<bool> exit_;\n \tint exitCode_;\n \n@@ -205,6 +204,11 @@ ThreadData *ThreadData::current()\n \treturn data;\n }\n \n+/**\n+ * \\typedef ConditionVariable\n+ * \\brief An alias for std::condition_variable\n+ */\n+\n /**\n  * \\typedef Mutex\n  * \\brief An alias for std::mutex\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex e78bb1d7..77ff3bd1 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -7,7 +7,6 @@\n \n #include <libcamera/camera_manager.h>\n \n-#include <condition_variable>\n #include <map>\n \n #include <libcamera/camera.h>\n@@ -63,7 +62,7 @@ private:\n \tvoid createPipelineHandlers();\n \tvoid cleanup();\n \n-\tstd::condition_variable cv_;\n+\tConditionVariable cv_;\n \tbool initialized_;\n \tint status_;\n \ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex 94263b2f..4afbb331 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -82,6 +82,6 @@ private:\n \tint efd_;\n \n \tlibcamera::Mutex bufferMutex_;\n-\tstd::condition_variable bufferCV_;\n+\tlibcamera::ConditionVariable bufferCV_;\n \tunsigned int bufferAvailableCount_;\n };\n","prefixes":["libcamera-devel","v5","01/12"]}