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>
This commit is contained in:
Laurent Pinchart
2019-08-12 02:36:37 +03:00
parent a66e5ca8c6
commit 0e65ed8145
11 changed files with 197 additions and 166 deletions

View File

@@ -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 */