libcamera: base: thread: Use acquire memo. when reading event dispatcher

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 <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2025-01-28 13:35:19 +01:00
parent d971584579
commit ebda108111

View File

@@ -244,7 +244,7 @@ Thread::Thread(std::string name)
Thread::~Thread()
{
delete data_->dispatcher_.load(std::memory_order_relaxed);
delete data_->dispatcher_.load(std::memory_order_acquire);
}
/**
@@ -379,7 +379,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;