From 0e65ed81453ce0ae8534b3fbc3f44a846d816910 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 12 Aug 2019 02:36:37 +0300 Subject: libcamera: signal: Split Slot implementation to reusable classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/bound_method.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/libcamera/bound_method.cpp (limited to 'src/libcamera/bound_method.cpp') 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 + +#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 msg = + utils::make_unique(this, pack); + object_->postMessage(std::move(msg)); + } +} + +} /* namespace libcamera */ -- cgit v1.2.1