summaryrefslogtreecommitdiff
path: root/src/libcamera/object.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-07-10 14:47:30 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-07-11 11:57:37 +0300
commitcc3ae13d9edf36473fb0c4c78b9490c355ce0096 (patch)
tree5216f22dd8eda2975bc41fc6ea9d504892a62f3f /src/libcamera/object.cpp
parent01b930964acdd9475d46044c459396f8c3cf8a79 (diff)
libcamera: signal: Support cross-thread signals
Allow signals to cross thread boundaries by posting them to the recipient through messages instead of calling the slot directly when the recipient lives in a different thread. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/object.cpp')
-rw-r--r--src/libcamera/object.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp
index fa228483..61787fad 100644
--- a/src/libcamera/object.cpp
+++ b/src/libcamera/object.cpp
@@ -10,6 +10,7 @@
#include <libcamera/signal.h>
#include "log.h"
+#include "message.h"
#include "thread.h"
/**
@@ -32,6 +33,10 @@ namespace libcamera {
* This allows implementing easy message passing between threads by inheriting
* from the Object class.
*
+ * Object slots connected to signals will also run in the context of the
+ * object's thread, regardless of whether the signal is emitted in the same or
+ * in another thread.
+ *
* \sa Message, Signal, Thread
*/
@@ -82,6 +87,16 @@ void Object::postMessage(std::unique_ptr<Message> msg)
*/
void Object::message(Message *msg)
{
+ switch (msg->type()) {
+ case Message::SignalMessage: {
+ SignalMessage *smsg = static_cast<SignalMessage *>(msg);
+ smsg->slot_->invokePack(smsg->pack_);
+ break;
+ }
+
+ default:
+ break;
+ }
}
/**