[libcamera-devel] [PATCH 2/4] libcamera: thread: Enforce dispatchMessages() call context with assert

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sun May 23 04:31:53 CEST 2021


The Thread::dispatchMessages() function is meant to be called from
within the thread only. Catch incorrect usage with an ASSERT().

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/libcamera/thread.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp
index 285b808332e8..bc1dcedea0d1 100644
--- a/src/libcamera/thread.cpp
+++ b/src/libcamera/thread.cpp
@@ -560,6 +560,8 @@ void Thread::removeMessages(Object *receiver)
  */
 void Thread::dispatchMessages(Message::Type type)
 {
+	ASSERT(data_ == ThreadData::current());
+
 	MutexLocker locker(data_->messages_.mutex_);
 
 	std::list<std::unique_ptr<Message>> &messages = data_->messages_.list_;
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list