diff options
author | Morph <[email protected]> | 2021-09-28 23:42:50 -0400 |
---|---|---|
committer | Morph <[email protected]> | 2021-10-01 23:38:59 -0400 |
commit | fadcee14f8fca1b76b4ea48b1cfd136ccae8d182 (patch) | |
tree | a5787938bc73ff1b0b539e0945d3544d06a7d6d2 /src/core/hle/service/friend/friend.cpp | |
parent | 3a33519598063175fb7c16c67e32784ed97d5017 (diff) | |
download | yuzu-android-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.gz yuzu-android-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/friend/friend.cpp')
-rw-r--r-- | src/core/hle/service/friend/friend.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index b58c152ce..68c9240ae 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -8,11 +8,10 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" -#include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/friend/errors.h" #include "core/hle/service/friend/friend.h" #include "core/hle/service/friend/friend_interface.h" +#include "core/hle/service/kernel_helpers.h" namespace Service::Friend { @@ -184,9 +183,9 @@ private: class INotificationService final : public ServiceFramework<INotificationService> { public: - explicit INotificationService(Common::UUID uuid_, Core::System& system_) - : ServiceFramework{system_, "INotificationService"}, uuid{uuid_}, notification_event{ - system.Kernel()} { + explicit INotificationService(Core::System& system_, Common::UUID uuid_) + : ServiceFramework{system_, "INotificationService"}, uuid{uuid_}, + service_context{system_, "INotificationService"} { // clang-format off static const FunctionInfo functions[] = { {0, &INotificationService::GetEvent, "GetEvent"}, @@ -197,8 +196,11 @@ public: RegisterHandlers(functions); - Kernel::KAutoObject::Create(std::addressof(notification_event)); - notification_event.Initialize("INotificationService:NotifyEvent"); + notification_event = service_context.CreateEvent("INotificationService:NotifyEvent"); + } + + ~INotificationService() override { + service_context.CloseEvent(notification_event); } private: @@ -207,7 +209,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(ResultSuccess); - rb.PushCopyObjects(notification_event.GetReadableEvent()); + rb.PushCopyObjects(notification_event->GetReadableEvent()); } void Clear(Kernel::HLERequestContext& ctx) { @@ -272,8 +274,10 @@ private: bool has_received_friend_request; }; - Common::UUID uuid{Common::INVALID_UUID}; - Kernel::KEvent notification_event; + Common::UUID uuid; + KernelHelpers::ServiceContext service_context; + + Kernel::KEvent* notification_event; std::queue<SizedNotificationInfo> notifications; States states{}; }; @@ -293,7 +297,7 @@ void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<INotificationService>(uuid, system); + rb.PushIpcInterface<INotificationService>(system, uuid); } Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, |