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/acc | |
| 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/acc')
| -rw-r--r-- | src/core/hle/service/acc/async_context.cpp | 17 | ||||
| -rw-r--r-- | src/core/hle/service/acc/async_context.h | 7 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/core/hle/service/acc/async_context.cpp b/src/core/hle/service/acc/async_context.cpp index 459323132..a49dfdec7 100644 --- a/src/core/hle/service/acc/async_context.cpp +++ b/src/core/hle/service/acc/async_context.cpp | |||
| @@ -4,15 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/kernel/k_event.h" | ||
| 7 | #include "core/hle/service/acc/async_context.h" | 8 | #include "core/hle/service/acc/async_context.h" |
| 8 | 9 | ||
| 9 | namespace Service::Account { | 10 | namespace Service::Account { |
| 10 | IAsyncContext::IAsyncContext(Core::System& system_) | 11 | IAsyncContext::IAsyncContext(Core::System& system_) |
| 11 | : ServiceFramework{system_, "IAsyncContext"}, compeletion_event{system_.Kernel()} { | 12 | : ServiceFramework{system_, "IAsyncContext"}, service_context{system_, "IAsyncContext"} { |
| 12 | |||
| 13 | Kernel::KAutoObject::Create(std::addressof(compeletion_event)); | ||
| 14 | compeletion_event.Initialize("IAsyncContext:CompletionEvent"); | ||
| 15 | |||
| 16 | // clang-format off | 13 | // clang-format off |
| 17 | static const FunctionInfo functions[] = { | 14 | static const FunctionInfo functions[] = { |
| 18 | {0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"}, | 15 | {0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"}, |
| @@ -23,6 +20,12 @@ IAsyncContext::IAsyncContext(Core::System& system_) | |||
| 23 | // clang-format on | 20 | // clang-format on |
| 24 | 21 | ||
| 25 | RegisterHandlers(functions); | 22 | RegisterHandlers(functions); |
| 23 | |||
| 24 | completion_event = service_context.CreateEvent("IAsyncContext:CompletionEvent"); | ||
| 25 | } | ||
| 26 | |||
| 27 | IAsyncContext::~IAsyncContext() { | ||
| 28 | service_context.CloseEvent(completion_event); | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { | 31 | void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { |
| @@ -30,7 +33,7 @@ void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { | |||
| 30 | 33 | ||
| 31 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 34 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 32 | rb.Push(ResultSuccess); | 35 | rb.Push(ResultSuccess); |
| 33 | rb.PushCopyObjects(compeletion_event.GetReadableEvent()); | 36 | rb.PushCopyObjects(completion_event->GetReadableEvent()); |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { | 39 | void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { |
| @@ -62,7 +65,7 @@ void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) { | |||
| 62 | 65 | ||
| 63 | void IAsyncContext::MarkComplete() { | 66 | void IAsyncContext::MarkComplete() { |
| 64 | is_complete.store(true); | 67 | is_complete.store(true); |
| 65 | compeletion_event.GetWritableEvent().Signal(); | 68 | completion_event->GetWritableEvent().Signal(); |
| 66 | } | 69 | } |
| 67 | 70 | ||
| 68 | } // namespace Service::Account | 71 | } // namespace Service::Account |
diff --git a/src/core/hle/service/acc/async_context.h b/src/core/hle/service/acc/async_context.h index c694b4946..cc3a0a9fe 100644 --- a/src/core/hle/service/acc/async_context.h +++ b/src/core/hle/service/acc/async_context.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include "core/hle/kernel/k_event.h" | 8 | #include "core/hle/service/kernel_helpers.h" |
| 9 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 10 | 10 | ||
| 11 | namespace Core { | 11 | namespace Core { |
| @@ -17,6 +17,7 @@ namespace Service::Account { | |||
| 17 | class IAsyncContext : public ServiceFramework<IAsyncContext> { | 17 | class IAsyncContext : public ServiceFramework<IAsyncContext> { |
| 18 | public: | 18 | public: |
| 19 | explicit IAsyncContext(Core::System& system_); | 19 | explicit IAsyncContext(Core::System& system_); |
| 20 | ~IAsyncContext() override; | ||
| 20 | 21 | ||
| 21 | void GetSystemEvent(Kernel::HLERequestContext& ctx); | 22 | void GetSystemEvent(Kernel::HLERequestContext& ctx); |
| 22 | void Cancel(Kernel::HLERequestContext& ctx); | 23 | void Cancel(Kernel::HLERequestContext& ctx); |
| @@ -30,8 +31,10 @@ protected: | |||
| 30 | 31 | ||
| 31 | void MarkComplete(); | 32 | void MarkComplete(); |
| 32 | 33 | ||
| 34 | KernelHelpers::ServiceContext service_context; | ||
| 35 | |||
| 33 | std::atomic<bool> is_complete{false}; | 36 | std::atomic<bool> is_complete{false}; |
| 34 | Kernel::KEvent compeletion_event; | 37 | Kernel::KEvent* completion_event; |
| 35 | }; | 38 | }; |
| 36 | 39 | ||
| 37 | } // namespace Service::Account | 40 | } // namespace Service::Account |