[libcamera-devel,v2,11/11] android: camera_request: Add thread safety annotation
diff mbox series

Message ID 20211129114453.3186042-12-hiroh@chromium.org
State Superseded
Headers show
Series
  • Introduce clang thread safety annotations
Related show

Commit Message

Hirokazu Honda Nov. 29, 2021, 11:44 a.m. UTC
This applies clang thread safety annotation to
Camera3RequestDescriptor. Mutex and MutexLocker there are
replaced with Mutex2 and MutexLocer2.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/android/camera_request.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Nov. 30, 2021, 4:34 a.m. UTC | #1
Hi Hiro,

Thank you for the patch.

On Mon, Nov 29, 2021 at 08:44:53PM +0900, Hirokazu Honda wrote:
> This applies clang thread safety annotation to
> Camera3RequestDescriptor. Mutex and MutexLocker there are
> replaced with Mutex2 and MutexLocer2.

Not anymore :-)

> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/android/camera_request.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/android/camera_request.h b/src/android/camera_request.h
> index 88d501a8..dfdc3324 100644
> --- a/src/android/camera_request.h
> +++ b/src/android/camera_request.h
> @@ -12,7 +12,8 @@
>  #include <vector>
>  
>  #include <libcamera/base/class.h>
> -#include <libcamera/base/thread.h>
> +#include <libcamera/base/mutex.h>
> +#include <libcamera/base/thread_annotations.h>

02/11 too.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  
>  #include <libcamera/camera.h>
>  #include <libcamera/framebuffer.h>
> @@ -57,7 +58,8 @@ public:
>  	};
>  
>  	/* Keeps track of streams requiring post-processing. */
> -	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
> +	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_
> +		LIBCAMERA_TSA_GUARDED_BY(streamsProcessMutex_);
>  	libcamera::Mutex streamsProcessMutex_;
>  
>  	Camera3RequestDescriptor(libcamera::Camera *camera,

Patch
diff mbox series

diff --git a/src/android/camera_request.h b/src/android/camera_request.h
index 88d501a8..dfdc3324 100644
--- a/src/android/camera_request.h
+++ b/src/android/camera_request.h
@@ -12,7 +12,8 @@ 
 #include <vector>
 
 #include <libcamera/base/class.h>
-#include <libcamera/base/thread.h>
+#include <libcamera/base/mutex.h>
+#include <libcamera/base/thread_annotations.h>
 
 #include <libcamera/camera.h>
 #include <libcamera/framebuffer.h>
@@ -57,7 +58,8 @@  public:
 	};
 
 	/* Keeps track of streams requiring post-processing. */
-	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
+	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_
+		LIBCAMERA_TSA_GUARDED_BY(streamsProcessMutex_);
 	libcamera::Mutex streamsProcessMutex_;
 
 	Camera3RequestDescriptor(libcamera::Camera *camera,