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

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

Commit Message

Hirokazu Honda Oct. 29, 2021, 4:14 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>
---
 src/android/camera_request.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Umang Jain Nov. 11, 2021, 6:09 p.m. UTC | #1
Hi Hiro,

Thank you for the patch.

On 10/29/21 9:44 AM, Hirokazu Honda wrote:
> 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>


Looks fine to me,

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   src/android/camera_request.h | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/android/camera_request.h b/src/android/camera_request.h
> index cfafa445..0c8e7287 100644
> --- a/src/android/camera_request.h
> +++ b/src/android/camera_request.h
> @@ -9,10 +9,11 @@
>   
>   #include <map>
>   #include <memory>
> -#include <mutex>
>   #include <vector>
>   
>   #include <libcamera/base/class.h>
> +#include <libcamera/base/mutex.h>
> +#include <libcamera/base/thread_annotations.h>
>   
>   #include <libcamera/camera.h>
>   #include <libcamera/framebuffer.h>
> @@ -46,8 +47,8 @@ public:
>   	};
>   
>   	/* Keeps track of streams requiring post-processing. */
> -	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
> -	std::mutex streamsProcessMutex_;
> +	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_ GUARDED_BY(streamsProcessMutex_);
> +	libcamera::Mutex2 streamsProcessMutex_;
>   
>   	Camera3RequestDescriptor(libcamera::Camera *camera,
>   				 const camera3_capture_request_t *camera3Request);

Patch
diff mbox series

diff --git a/src/android/camera_request.h b/src/android/camera_request.h
index cfafa445..0c8e7287 100644
--- a/src/android/camera_request.h
+++ b/src/android/camera_request.h
@@ -9,10 +9,11 @@ 
 
 #include <map>
 #include <memory>
-#include <mutex>
 #include <vector>
 
 #include <libcamera/base/class.h>
+#include <libcamera/base/mutex.h>
+#include <libcamera/base/thread_annotations.h>
 
 #include <libcamera/camera.h>
 #include <libcamera/framebuffer.h>
@@ -46,8 +47,8 @@  public:
 	};
 
 	/* Keeps track of streams requiring post-processing. */
-	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
-	std::mutex streamsProcessMutex_;
+	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_ GUARDED_BY(streamsProcessMutex_);
+	libcamera::Mutex2 streamsProcessMutex_;
 
 	Camera3RequestDescriptor(libcamera::Camera *camera,
 				 const camera3_capture_request_t *camera3Request);