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:
33
src/libcamera/bound_method.cpp
Normal file
33
src/libcamera/bound_method.cpp
Normal 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 */
|
||||
Reference in New Issue
Block a user