summaryrefslogtreecommitdiff
path: root/src/libcamera/object.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-12 00:06:48 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-17 18:32:30 +0300
commit5a954cb8b57ec1869958985f6557c38bb5503e5a (patch)
treee21d6b22f823f46b6e0544236697f7ca7eaf75a4 /src/libcamera/object.cpp
parentd5d7b71521cb9ad72505d66346227688134b8576 (diff)
libcamera: object: Notify objects of thread move
Send a synchronous message to objects just before they get moved to a new thread. This allows the object to perform any required processing. EventNotifier and Timer objects will use this mechanism to move themselves to the new thread's event disaptcher. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/object.cpp')
-rw-r--r--src/libcamera/object.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp
index 7d70ce21..bbb28f26 100644
--- a/src/libcamera/object.cpp
+++ b/src/libcamera/object.cpp
@@ -135,6 +135,10 @@ void Object::invokeMethod(BoundMethodBase *method, void *args)
* This method moves the object from the current thread to the new \a thread.
* It shall be called from the thread in which the object currently lives,
* otherwise the behaviour is undefined.
+ *
+ * Before the object is moved, a Message::ThreadMoveMessage message is sent to
+ * it. The message() method can be reimplement in derived classes to be notified
+ * of the upcoming thread move and perform any required processing.
*/
void Object::moveToThread(Thread *thread)
{
@@ -143,9 +147,17 @@ void Object::moveToThread(Thread *thread)
if (thread_ == thread)
return;
+ notifyThreadMove();
+
thread->moveObject(this);
}
+void Object::notifyThreadMove()
+{
+ Message msg(Message::ThreadMoveMessage);
+ message(&msg);
+}
+
void Object::connect(SignalBase *signal)
{
signals_.push_back(signal);