Message ID | 20211129114453.3186042-2-hiroh@chromium.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Hiro, Thank you for the patch. On Mon, Nov 29, 2021 at 08:44:43PM +0900, Hirokazu Honda wrote: > ConditionVariable is alias to std::condition_variable. This replaces > std::condition_variable with the ConditionVariable. It enables > replacing ConditionVariable implementation easily in the following > patches. > > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > include/libcamera/base/semaphore.h | 4 +--- > include/libcamera/base/thread.h | 2 ++ > src/android/camera_stream.h | 3 +-- > src/libcamera/base/thread.cpp | 3 +-- > src/libcamera/camera_manager.cpp | 3 +-- > src/v4l2/v4l2_camera.h | 2 +- > 6 files changed, 7 insertions(+), 10 deletions(-) > > diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h > index ae87d319..ec05fad3 100644 > --- a/include/libcamera/base/semaphore.h > +++ b/include/libcamera/base/semaphore.h > @@ -7,8 +7,6 @@ > > #pragma once > > -#include <condition_variable> > - > #include <libcamera/base/private.h> > #include <libcamera/base/thread.h> > > @@ -26,7 +24,7 @@ public: > > private: > Mutex mutex_; > - std::condition_variable cv_; > + ConditionVariable cv_; > unsigned int available_; > }; > > diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h > index 32ebc80a..1ebf8363 100644 > --- a/include/libcamera/base/thread.h > +++ b/include/libcamera/base/thread.h > @@ -7,6 +7,7 @@ > > #pragma once > > +#include <condition_variable> > #include <memory> > #include <mutex> > #include <sys/types.h> > @@ -26,6 +27,7 @@ class Object; > class ThreadData; > class ThreadMain; > > +using ConditionVariable = std::condition_variable; > using Mutex = std::mutex; > using MutexLocker = std::unique_lock<std::mutex>; > > diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h > index e9da75f0..e4808369 100644 > --- a/src/android/camera_stream.h > +++ b/src/android/camera_stream.h > @@ -7,7 +7,6 @@ > > #pragma once > > -#include <condition_variable> > #include <memory> > #include <mutex> > #include <queue> > @@ -154,7 +153,7 @@ private: > PostProcessor *postProcessor_; > > libcamera::Mutex mutex_; > - std::condition_variable cv_; > + libcamera::ConditionVariable cv_; > > std::queue<Camera3RequestDescriptor::StreamBuffer *> requests_; > State state_ = State::Stopped; > diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp > index d0ca30e3..58e1265f 100644 > --- a/src/libcamera/base/thread.cpp > +++ b/src/libcamera/base/thread.cpp > @@ -8,7 +8,6 @@ > #include <libcamera/base/thread.h> > > #include <atomic> > -#include <condition_variable> > #include <list> > #include <sys/syscall.h> > #include <sys/types.h> > @@ -158,7 +157,7 @@ private: > > std::atomic<EventDispatcher *> dispatcher_; > > - std::condition_variable cv_; > + ConditionVariable cv_; > std::atomic<bool> exit_; > int exitCode_; > > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp > index e78bb1d7..77ff3bd1 100644 > --- a/src/libcamera/camera_manager.cpp > +++ b/src/libcamera/camera_manager.cpp > @@ -7,7 +7,6 @@ > > #include <libcamera/camera_manager.h> > > -#include <condition_variable> > #include <map> > > #include <libcamera/camera.h> > @@ -63,7 +62,7 @@ private: > void createPipelineHandlers(); > void cleanup(); > > - std::condition_variable cv_; > + ConditionVariable cv_; > bool initialized_; > int status_; > > diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h > index 94263b2f..4afbb331 100644 > --- a/src/v4l2/v4l2_camera.h > +++ b/src/v4l2/v4l2_camera.h > @@ -82,6 +82,6 @@ private: > int efd_; > > libcamera::Mutex bufferMutex_; > - std::condition_variable bufferCV_; > + libcamera::ConditionVariable bufferCV_; > unsigned int bufferAvailableCount_; > };
diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h index ae87d319..ec05fad3 100644 --- a/include/libcamera/base/semaphore.h +++ b/include/libcamera/base/semaphore.h @@ -7,8 +7,6 @@ #pragma once -#include <condition_variable> - #include <libcamera/base/private.h> #include <libcamera/base/thread.h> @@ -26,7 +24,7 @@ public: private: Mutex mutex_; - std::condition_variable cv_; + ConditionVariable cv_; unsigned int available_; }; diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h index 32ebc80a..1ebf8363 100644 --- a/include/libcamera/base/thread.h +++ b/include/libcamera/base/thread.h @@ -7,6 +7,7 @@ #pragma once +#include <condition_variable> #include <memory> #include <mutex> #include <sys/types.h> @@ -26,6 +27,7 @@ class Object; class ThreadData; class ThreadMain; +using ConditionVariable = std::condition_variable; using Mutex = std::mutex; using MutexLocker = std::unique_lock<std::mutex>; diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index e9da75f0..e4808369 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -7,7 +7,6 @@ #pragma once -#include <condition_variable> #include <memory> #include <mutex> #include <queue> @@ -154,7 +153,7 @@ private: PostProcessor *postProcessor_; libcamera::Mutex mutex_; - std::condition_variable cv_; + libcamera::ConditionVariable cv_; std::queue<Camera3RequestDescriptor::StreamBuffer *> requests_; State state_ = State::Stopped; diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index d0ca30e3..58e1265f 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -8,7 +8,6 @@ #include <libcamera/base/thread.h> #include <atomic> -#include <condition_variable> #include <list> #include <sys/syscall.h> #include <sys/types.h> @@ -158,7 +157,7 @@ private: std::atomic<EventDispatcher *> dispatcher_; - std::condition_variable cv_; + ConditionVariable cv_; std::atomic<bool> exit_; int exitCode_; diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index e78bb1d7..77ff3bd1 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -7,7 +7,6 @@ #include <libcamera/camera_manager.h> -#include <condition_variable> #include <map> #include <libcamera/camera.h> @@ -63,7 +62,7 @@ private: void createPipelineHandlers(); void cleanup(); - std::condition_variable cv_; + ConditionVariable cv_; bool initialized_; int status_; diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index 94263b2f..4afbb331 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -82,6 +82,6 @@ private: int efd_; libcamera::Mutex bufferMutex_; - std::condition_variable bufferCV_; + libcamera::ConditionVariable bufferCV_; unsigned int bufferAvailableCount_; };
ConditionVariable is alias to std::condition_variable. This replaces std::condition_variable with the ConditionVariable. It enables replacing ConditionVariable implementation easily in the following patches. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- include/libcamera/base/semaphore.h | 4 +--- include/libcamera/base/thread.h | 2 ++ src/android/camera_stream.h | 3 +-- src/libcamera/base/thread.cpp | 3 +-- src/libcamera/camera_manager.cpp | 3 +-- src/v4l2/v4l2_camera.h | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-)