blob: 5a1d43c11a0ca28bec50d6c4b2b1136e9bc67ae2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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/kernel_helpers.h"
#include "core/hle/service/os/event.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
|