summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-01-18 23:26:44 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-01-25 02:39:22 +0200
commit6f1bd9cf55efebf6bae196a128a5b6c0fd515e17 (patch)
tree63fe0ffdac73611ecef60f15f02f95715b39ae75 /include
parent56f817892cb444f3c0931357373cbb5961af4b9b (diff)
libcamera: object: Add and use thread-bound assertion
Several functions in libcamera classes are marked as thread-bound, restricting the contexts in which those functions can be called. There is no infrastructure to enforce these restrictions, causing difficult to debug race conditions when they are not met by callers. As a first step to solve this, add an assertThreadBound() protected function to the Object class to test if the calling thread context is valid, and use it in member functions of Object subclasses marked as thread-bound. This replaces manual tests in a few locations. The thread-bound member functions of classes that do not inherit from Object are not checked, and neither are the functions of classes marked as thread-bound at the class level. These issue should be addressed in the future. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/base/object.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/libcamera/base/object.h b/include/libcamera/base/object.h
index 93333636..cb7e0a13 100644
--- a/include/libcamera/base/object.h
+++ b/include/libcamera/base/object.h
@@ -49,6 +49,8 @@ public:
protected:
virtual void message(Message *msg);
+ bool assertThreadBound(const char *message);
+
private:
friend class SignalBase;
friend class Thread;