libcamera: base: thread: Apply clang thread safety annotation

This annotates member variables of ThreadData by clang thread
safety annotations.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2022-11-03 18:50:38 +05:30 committed by Umang Jain
parent b5d26eab4d
commit c39885ed9b

View file

@ -151,7 +151,7 @@ private:
friend class ThreadMain; friend class ThreadMain;
Thread *thread_; Thread *thread_;
bool running_; bool running_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
pid_t tid_; pid_t tid_;
Mutex mutex_; Mutex mutex_;
@ -422,11 +422,15 @@ bool Thread::wait(utils::duration duration)
{ {
MutexLocker locker(data_->mutex_); MutexLocker locker(data_->mutex_);
auto isRunning = ([&]() LIBCAMERA_TSA_REQUIRES(data_->mutex_) {
return !data_->running_;
});
if (duration == utils::duration::max()) if (duration == utils::duration::max())
data_->cv_.wait(locker, [&]() { return !data_->running_; }); data_->cv_.wait(locker, isRunning);
else else
hasFinished = data_->cv_.wait_for(locker, duration, hasFinished = data_->cv_.wait_for(locker, duration,
[&]() { return !data_->running_; }); isRunning);
} }
if (thread_.joinable()) if (thread_.joinable())