summaryrefslogtreecommitdiff
path: root/src/libcamera/bound_method.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-12 02:36:37 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-17 18:32:28 +0300
commit0e65ed81453ce0ae8534b3fbc3f44a846d816910 (patch)
treeeaad921355f681a0c91434896f7ea539a01f2382 /src/libcamera/bound_method.cpp
parenta66e5ca8c61093c5b927bb072c595560fd5d5d38 (diff)
libcamera: signal: Split Slot implementation to reusable classes
Move the Slot* classes to bound_method.{h,cpp} and rename them to Bound*Method*. They will be reused to implement asynchronous method invocation similar to cross-thread signal delivery. This is only a move and rename, no functional changes are included. 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/bound_method.cpp')
-rw-r--r--src/libcamera/bound_method.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libcamera/bound_method.cpp b/src/libcamera/bound_method.cpp
new file mode 100644
index 00000000..0a2d61a6
--- /dev/null
+++ b/src/libcamera/bound_method.cpp
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * bound_method.cpp - Method bind and invocation
+ */
+
+#include <libcamera/bound_method.h>
+
+#include "message.h"
+#include "thread.h"
+#include "utils.h"
+
+namespace libcamera {
+
+void BoundMethodBase::disconnect(SignalBase *signal)
+{
+ if (object_)
+ object_->disconnect(signal);
+}
+
+void BoundMethodBase::activatePack(void *pack)
+{
+ if (Thread::current() == object_->thread()) {
+ invokePack(pack);
+ } else {
+ std::unique_ptr<Message> msg =
+ utils::make_unique<SignalMessage>(this, pack);
+ object_->postMessage(std::move(msg));
+ }
+}
+
+} /* namespace libcamera */