[RFC PATCH v1] libcamera: thread: Use `acquire` memo. when reading event dispatcher
Barnabás Pőcze
pobrn at protonmail.com
Tue Jan 28 14:03:10 CET 2025
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 at protonmail.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;
--
2.48.1
More information about the libcamera-devel
mailing list