[RFC,v1] libcamera: thread: Use `acquire` memo. when reading event dispatcher
diff mbox series

Message ID 20250128130308.509297-1-pobrn@protonmail.com
State New
Headers show
Series
  • [RFC,v1] libcamera: thread: Use `acquire` memo. when reading event dispatcher
Related show

Commit Message

Barnabás Pőcze Jan. 28, 2025, 1:03 p.m. UTC
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(-)

Patch
diff mbox series

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;