Message ID | 20250128130308.509297-1-pobrn@protonmail.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Barnabás, Thank you for the patch. On Tue, Jan 28, 2025 at 01:03:10PM +0000, Barnabás Pőcze wrote: > Use `std::memory_order_acquire` everywhere the dispatcher is loaded > to guarantee synchronization with the release-store that places > the pointer there. > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/base/thread.cpp | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp > index 319bfda9a..de60567f6 100644 > --- a/src/libcamera/base/thread.cpp > +++ b/src/libcamera/base/thread.cpp > @@ -238,7 +238,7 @@ Thread::Thread() > > Thread::~Thread() > { > - delete data_->dispatcher_.load(std::memory_order_relaxed); > + delete data_->dispatcher_.load(std::memory_order_acquire); > delete data_; > } > > @@ -371,7 +371,7 @@ void Thread::exit(int code) > data_->exitCode_ = code; > data_->exit_.store(true, std::memory_order_release); > > - EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_relaxed); > + EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_acquire); > if (!dispatcher) > return; >
diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index 319bfda9a..de60567f6 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -238,7 +238,7 @@ Thread::Thread() Thread::~Thread() { - delete data_->dispatcher_.load(std::memory_order_relaxed); + delete data_->dispatcher_.load(std::memory_order_acquire); delete data_; } @@ -371,7 +371,7 @@ void Thread::exit(int code) data_->exitCode_ = code; data_->exit_.store(true, std::memory_order_release); - EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_relaxed); + EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_acquire); if (!dispatcher) return;
Use `std::memory_order_acquire` everywhere the dispatcher is loaded to guarantee synchronization with the release-store that places the pointer there. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> --- src/libcamera/base/thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)