summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/applet_data_broker.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-01-03 07:16:27 +0100
committerLiam <byteslice@airmail.cc>2024-01-30 02:17:33 +0100
commit8a146469c0639ff402e77da8843072ce1f2bce0c (patch)
treec5dbc016c8ff1affaa06d9bfe7b580b468fed1ba /src/core/hle/service/am/applet_data_broker.h
parentam: rework IStorage for transfer storage (diff)
downloadyuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.tar
yuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.tar.gz
yuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.tar.bz2
yuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.tar.lz
yuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.tar.xz
yuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.tar.zst
yuzu-8a146469c0639ff402e77da8843072ce1f2bce0c.zip
Diffstat (limited to 'src/core/hle/service/am/applet_data_broker.h')
-rw-r--r--src/core/hle/service/am/applet_data_broker.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/core/hle/service/am/applet_data_broker.h b/src/core/hle/service/am/applet_data_broker.h
new file mode 100644
index 000000000..12326fd04
--- /dev/null
+++ b/src/core/hle/service/am/applet_data_broker.h
@@ -0,0 +1,80 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <deque>
+#include <memory>
+#include <mutex>
+
+#include "core/hle/service/event.h"
+#include "core/hle/service/kernel_helpers.h"
+
+union Result;
+
+namespace Service::AM {
+
+struct Applet;
+class IStorage;
+
+class AppletStorageChannel {
+public:
+ explicit AppletStorageChannel(KernelHelpers::ServiceContext& ctx);
+ ~AppletStorageChannel();
+
+ void Push(std::shared_ptr<IStorage> storage);
+ Result Pop(std::shared_ptr<IStorage>* out_storage);
+ Kernel::KReadableEvent* GetEvent();
+
+private:
+ std::mutex m_lock{};
+ std::deque<std::shared_ptr<IStorage>> m_data{};
+ Event m_event;
+};
+
+class AppletDataBroker {
+public:
+ explicit AppletDataBroker(Core::System& system_);
+ ~AppletDataBroker();
+
+ AppletStorageChannel& GetInData() {
+ return in_data;
+ }
+
+ AppletStorageChannel& GetInteractiveInData() {
+ return interactive_in_data;
+ }
+
+ AppletStorageChannel& GetOutData() {
+ return out_data;
+ }
+
+ AppletStorageChannel& GetInteractiveOutData() {
+ return interactive_out_data;
+ }
+
+ Event& GetStateChangedEvent() {
+ return state_changed_event;
+ }
+
+ bool IsCompleted() const {
+ return is_completed;
+ }
+
+ void SignalCompletion();
+
+private:
+ Core::System& system;
+ KernelHelpers::ServiceContext context;
+
+ AppletStorageChannel in_data;
+ AppletStorageChannel interactive_in_data;
+ AppletStorageChannel out_data;
+ AppletStorageChannel interactive_out_data;
+ Event state_changed_event;
+
+ std::mutex lock;
+ bool is_completed;
+};
+
+} // namespace Service::AM