Pass shared pointers by value in applet infrastructure

This is more optimal than crefs when used together with std::move
This commit is contained in:
Billy Laws 2022-04-15 12:19:48 +01:00 committed by PixelyIon
parent 8ccef733ff
commit 2873f11baa
6 changed files with 14 additions and 14 deletions

View File

@ -6,9 +6,9 @@
namespace skyline::applet { namespace skyline::applet {
std::shared_ptr<service::am::IApplet> CreateApplet( std::shared_ptr<service::am::IApplet> CreateApplet(
const DeviceState &state, service::ServiceManager &manager, const DeviceState &state, service::ServiceManager &manager,
applet::AppletId appletId, const std::shared_ptr<kernel::type::KEvent> &onAppletStateChanged, applet::AppletId appletId, std::shared_ptr<kernel::type::KEvent> onAppletStateChanged,
const std::shared_ptr<kernel::type::KEvent> &onNormalDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onNormalDataPushFromApplet,
const std::shared_ptr<kernel::type::KEvent> &onInteractiveDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onInteractiveDataPushFromApplet,
service::applet::LibraryAppletMode appletMode) { service::applet::LibraryAppletMode appletMode) {
switch (appletId) { switch (appletId) {
default: default:

View File

@ -74,8 +74,8 @@ namespace skyline::applet {
*/ */
std::shared_ptr<service::am::IApplet> CreateApplet( std::shared_ptr<service::am::IApplet> CreateApplet(
const DeviceState &state, service::ServiceManager &manager, const DeviceState &state, service::ServiceManager &manager,
applet::AppletId appletId, const std::shared_ptr<kernel::type::KEvent> &onAppletStateChanged, applet::AppletId appletId, std::shared_ptr<kernel::type::KEvent> onAppletStateChanged,
const std::shared_ptr<kernel::type::KEvent> &onNormalDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onNormalDataPushFromApplet,
const std::shared_ptr<kernel::type::KEvent> &onInteractiveDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onInteractiveDataPushFromApplet,
service::applet::LibraryAppletMode appletMode); service::applet::LibraryAppletMode appletMode);
} }

View File

@ -12,13 +12,13 @@ namespace skyline::service::am {
IApplet::~IApplet() = default; IApplet::~IApplet() = default;
void IApplet::PushNormalDataAndSignal(const std::shared_ptr<IStorage> &data) { void IApplet::PushNormalDataAndSignal(std::shared_ptr<IStorage> data) {
normalOutputData.emplace(data); normalOutputData.emplace(std::move(data));
onNormalDataPushFromApplet->Signal(); onNormalDataPushFromApplet->Signal();
} }
void IApplet::PushInteractiveDataAndSignal(const std::shared_ptr<IStorage> &data) { void IApplet::PushInteractiveDataAndSignal(std::shared_ptr<IStorage> data) {
interactiveOutputData.emplace(data); interactiveOutputData.emplace(std::move(data));
onInteractiveDataPushFromApplet->Signal(); onInteractiveDataPushFromApplet->Signal();
} }

View File

@ -26,12 +26,12 @@ namespace skyline::service::am {
/** /**
* @brief Utility to send data to the guest and trigger the onNormalDataPushFromApplet event * @brief Utility to send data to the guest and trigger the onNormalDataPushFromApplet event
*/ */
void PushNormalDataAndSignal(const std::shared_ptr<IStorage> &data); void PushNormalDataAndSignal(std::shared_ptr<IStorage> data);
/** /**
* @brief Utility to send data to the guest and trigger the onInteractiveDataPushFromApplet event * @brief Utility to send data to the guest and trigger the onInteractiveDataPushFromApplet event
*/ */
void PushInteractiveDataAndSignal(const std::shared_ptr<IStorage> &data); void PushInteractiveDataAndSignal(std::shared_ptr<IStorage> data);
public: public:
IApplet(const DeviceState &state, ServiceManager &manager, std::shared_ptr<kernel::type::KEvent> onAppletStateChanged, std::shared_ptr<kernel::type::KEvent> onNormalDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onInteractiveDataPushFromApplet, applet::LibraryAppletMode appletMode); IApplet(const DeviceState &state, ServiceManager &manager, std::shared_ptr<kernel::type::KEvent> onAppletStateChanged, std::shared_ptr<kernel::type::KEvent> onNormalDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onInteractiveDataPushFromApplet, applet::LibraryAppletMode appletMode);

View File

@ -21,6 +21,6 @@ namespace skyline::service::am {
~TransferMemoryIStorage() override; ~TransferMemoryIStorage() override;
virtual span<u8> GetSpan() override; span<u8> GetSpan() override;
}; };
} }

View File

@ -21,6 +21,6 @@ namespace skyline::service::am {
~VectorIStorage() override; ~VectorIStorage() override;
virtual span<u8> GetSpan() override; span<u8> GetSpan() override;
}; };
} }