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/nim | |
| 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/nim')
| -rw-r--r-- | src/core/hle/service/nim/nim.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index 7447cc38f..30fb060b8 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp | |||
| @@ -7,9 +7,8 @@ | |||
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/k_event.h" | 9 | #include "core/hle/kernel/k_event.h" |
| 10 | #include "core/hle/kernel/k_readable_event.h" | ||
| 11 | #include "core/hle/kernel/k_writable_event.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/service/kernel_helpers.h" | ||
| 13 | #include "core/hle/service/nim/nim.h" | 12 | #include "core/hle/service/nim/nim.h" |
| 14 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 15 | #include "core/hle/service/sm/sm.h" | 14 | #include "core/hle/service/sm/sm.h" |
| @@ -301,7 +300,7 @@ class IEnsureNetworkClockAvailabilityService final | |||
| 301 | public: | 300 | public: |
| 302 | explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) | 301 | explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) |
| 303 | : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"}, | 302 | : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"}, |
| 304 | finished_event{system.Kernel()} { | 303 | service_context{system_, "IEnsureNetworkClockAvailabilityService"} { |
| 305 | static const FunctionInfo functions[] = { | 304 | static const FunctionInfo functions[] = { |
| 306 | {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, | 305 | {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, |
| 307 | {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, | 306 | {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, |
| @@ -313,17 +312,19 @@ public: | |||
| 313 | }; | 312 | }; |
| 314 | RegisterHandlers(functions); | 313 | RegisterHandlers(functions); |
| 315 | 314 | ||
| 316 | Kernel::KAutoObject::Create(std::addressof(finished_event)); | 315 | finished_event = |
| 317 | finished_event.Initialize("IEnsureNetworkClockAvailabilityService:FinishEvent"); | 316 | service_context.CreateEvent("IEnsureNetworkClockAvailabilityService:FinishEvent"); |
| 318 | } | 317 | } |
| 319 | 318 | ||
| 320 | private: | 319 | ~IEnsureNetworkClockAvailabilityService() override { |
| 321 | Kernel::KEvent finished_event; | 320 | service_context.CloseEvent(finished_event); |
| 321 | } | ||
| 322 | 322 | ||
| 323 | private: | ||
| 323 | void StartTask(Kernel::HLERequestContext& ctx) { | 324 | void StartTask(Kernel::HLERequestContext& ctx) { |
| 324 | // No need to connect to the internet, just finish the task straight away. | 325 | // No need to connect to the internet, just finish the task straight away. |
| 325 | LOG_DEBUG(Service_NIM, "called"); | 326 | LOG_DEBUG(Service_NIM, "called"); |
| 326 | finished_event.GetWritableEvent().Signal(); | 327 | finished_event->GetWritableEvent().Signal(); |
| 327 | IPC::ResponseBuilder rb{ctx, 2}; | 328 | IPC::ResponseBuilder rb{ctx, 2}; |
| 328 | rb.Push(ResultSuccess); | 329 | rb.Push(ResultSuccess); |
| 329 | } | 330 | } |
| @@ -333,7 +334,7 @@ private: | |||
| 333 | 334 | ||
| 334 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 335 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 335 | rb.Push(ResultSuccess); | 336 | rb.Push(ResultSuccess); |
| 336 | rb.PushCopyObjects(finished_event.GetReadableEvent()); | 337 | rb.PushCopyObjects(finished_event->GetReadableEvent()); |
| 337 | } | 338 | } |
| 338 | 339 | ||
| 339 | void GetResult(Kernel::HLERequestContext& ctx) { | 340 | void GetResult(Kernel::HLERequestContext& ctx) { |
| @@ -345,7 +346,7 @@ private: | |||
| 345 | 346 | ||
| 346 | void Cancel(Kernel::HLERequestContext& ctx) { | 347 | void Cancel(Kernel::HLERequestContext& ctx) { |
| 347 | LOG_DEBUG(Service_NIM, "called"); | 348 | LOG_DEBUG(Service_NIM, "called"); |
| 348 | finished_event.GetWritableEvent().Clear(); | 349 | finished_event->GetWritableEvent().Clear(); |
| 349 | IPC::ResponseBuilder rb{ctx, 2}; | 350 | IPC::ResponseBuilder rb{ctx, 2}; |
| 350 | rb.Push(ResultSuccess); | 351 | rb.Push(ResultSuccess); |
| 351 | } | 352 | } |
| @@ -368,6 +369,10 @@ private: | |||
| 368 | rb.Push(ResultSuccess); | 369 | rb.Push(ResultSuccess); |
| 369 | rb.PushRaw<s64>(server_time); | 370 | rb.PushRaw<s64>(server_time); |
| 370 | } | 371 | } |
| 372 | |||
| 373 | KernelHelpers::ServiceContext service_context; | ||
| 374 | |||
| 375 | Kernel::KEvent* finished_event; | ||
| 371 | }; | 376 | }; |
| 372 | 377 | ||
| 373 | class NTC final : public ServiceFramework<NTC> { | 378 | class NTC final : public ServiceFramework<NTC> { |