diff options
| author | 2021-09-28 23:42:50 -0400 | |
|---|---|---|
| committer | 2021-10-01 23:38:59 -0400 | |
| commit | fadcee14f8fca1b76b4ea48b1cfd136ccae8d182 (patch) | |
| tree | a5787938bc73ff1b0b539e0945d3544d06a7d6d2 /src/core/hle/service/bcat | |
| parent | Merge pull request #7102 from Morph1984/remove-boxcat (diff) | |
| download | yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.gz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.xz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.zip | |
service: Replace service event creation with ServiceContext::CreateEvent
The service context helps to manage all created events and allows us to close them upon destruction.
Diffstat (limited to 'src/core/hle/service/bcat')
| -rw-r--r-- | src/core/hle/service/bcat/backend/backend.cpp | 22 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/backend/backend.h | 10 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/bcat_module.cpp | 4 |
3 files changed, 21 insertions, 15 deletions
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index a78544c88..4c7d3bb6e 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp | |||
| @@ -5,22 +5,24 @@ | |||
| 5 | #include "common/hex_util.h" | 5 | #include "common/hex_util.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/kernel/k_readable_event.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 9 | #include "core/hle/kernel/k_writable_event.h" | ||
| 10 | #include "core/hle/lock.h" | 9 | #include "core/hle/lock.h" |
| 11 | #include "core/hle/service/bcat/backend/backend.h" | 10 | #include "core/hle/service/bcat/backend/backend.h" |
| 12 | 11 | ||
| 13 | namespace Service::BCAT { | 12 | namespace Service::BCAT { |
| 14 | 13 | ||
| 15 | ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, | 14 | ProgressServiceBackend::ProgressServiceBackend(Core::System& system, std::string_view event_name) |
| 16 | std::string_view event_name) | 15 | : service_context{system, "ProgressServiceBackend"} { |
| 17 | : update_event{kernel} { | 16 | update_event = service_context.CreateEvent("ProgressServiceBackend:UpdateEvent:" + |
| 18 | Kernel::KAutoObject::Create(std::addressof(update_event)); | 17 | std::string(event_name)); |
| 19 | update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name)); | 18 | } |
| 19 | |||
| 20 | ProgressServiceBackend::~ProgressServiceBackend() { | ||
| 21 | service_context.CloseEvent(update_event); | ||
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | Kernel::KReadableEvent& ProgressServiceBackend::GetEvent() { | 24 | Kernel::KReadableEvent& ProgressServiceBackend::GetEvent() { |
| 23 | return update_event.GetReadableEvent(); | 25 | return update_event->GetReadableEvent(); |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { | 28 | DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { |
| @@ -88,9 +90,9 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) { | |||
| 88 | void ProgressServiceBackend::SignalUpdate() { | 90 | void ProgressServiceBackend::SignalUpdate() { |
| 89 | if (need_hle_lock) { | 91 | if (need_hle_lock) { |
| 90 | std::lock_guard lock(HLE::g_hle_lock); | 92 | std::lock_guard lock(HLE::g_hle_lock); |
| 91 | update_event.GetWritableEvent().Signal(); | 93 | update_event->GetWritableEvent().Signal(); |
| 92 | } else { | 94 | } else { |
| 93 | update_event.GetWritableEvent().Signal(); | 95 | update_event->GetWritableEvent().Signal(); |
| 94 | } | 96 | } |
| 95 | } | 97 | } |
| 96 | 98 | ||
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index e79a9c2ad..749e046c7 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "core/file_sys/vfs_types.h" | 13 | #include "core/file_sys/vfs_types.h" |
| 14 | #include "core/hle/kernel/k_event.h" | ||
| 15 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | #include "core/hle/service/kernel_helpers.h" | ||
| 16 | 16 | ||
| 17 | namespace Core { | 17 | namespace Core { |
| 18 | class System; | 18 | class System; |
| @@ -70,6 +70,8 @@ class ProgressServiceBackend { | |||
| 70 | friend class IBcatService; | 70 | friend class IBcatService; |
| 71 | 71 | ||
| 72 | public: | 72 | public: |
| 73 | ~ProgressServiceBackend(); | ||
| 74 | |||
| 73 | // Clients should call this with true if any of the functions are going to be called from a | 75 | // Clients should call this with true if any of the functions are going to be called from a |
| 74 | // non-HLE thread and this class need to lock the hle mutex. (default is false) | 76 | // non-HLE thread and this class need to lock the hle mutex. (default is false) |
| 75 | void SetNeedHLELock(bool need); | 77 | void SetNeedHLELock(bool need); |
| @@ -97,15 +99,17 @@ public: | |||
| 97 | void FinishDownload(ResultCode result); | 99 | void FinishDownload(ResultCode result); |
| 98 | 100 | ||
| 99 | private: | 101 | private: |
| 100 | explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name); | 102 | explicit ProgressServiceBackend(Core::System& system, std::string_view event_name); |
| 101 | 103 | ||
| 102 | Kernel::KReadableEvent& GetEvent(); | 104 | Kernel::KReadableEvent& GetEvent(); |
| 103 | DeliveryCacheProgressImpl& GetImpl(); | 105 | DeliveryCacheProgressImpl& GetImpl(); |
| 104 | 106 | ||
| 105 | void SignalUpdate(); | 107 | void SignalUpdate(); |
| 106 | 108 | ||
| 109 | KernelHelpers::ServiceContext service_context; | ||
| 110 | |||
| 107 | DeliveryCacheProgressImpl impl{}; | 111 | DeliveryCacheProgressImpl impl{}; |
| 108 | Kernel::KEvent update_event; | 112 | Kernel::KEvent* update_event; |
| 109 | bool need_hle_lock = false; | 113 | bool need_hle_lock = false; |
| 110 | }; | 114 | }; |
| 111 | 115 | ||
diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp index 701f634f8..27e9b8df8 100644 --- a/src/core/hle/service/bcat/bcat_module.cpp +++ b/src/core/hle/service/bcat/bcat_module.cpp | |||
| @@ -127,8 +127,8 @@ public: | |||
| 127 | explicit IBcatService(Core::System& system_, Backend& backend_) | 127 | explicit IBcatService(Core::System& system_, Backend& backend_) |
| 128 | : ServiceFramework{system_, "IBcatService"}, backend{backend_}, | 128 | : ServiceFramework{system_, "IBcatService"}, backend{backend_}, |
| 129 | progress{{ | 129 | progress{{ |
| 130 | ProgressServiceBackend{system_.Kernel(), "Normal"}, | 130 | ProgressServiceBackend{system_, "Normal"}, |
| 131 | ProgressServiceBackend{system_.Kernel(), "Directory"}, | 131 | ProgressServiceBackend{system_, "Directory"}, |
| 132 | }} { | 132 | }} { |
| 133 | // clang-format off | 133 | // clang-format off |
| 134 | static const FunctionInfo functions[] = { | 134 | static const FunctionInfo functions[] = { |