From 16e9d1567410de58b8b426fffc93d1a5fe33d834 Mon Sep 17 00:00:00 2001
From: mageven <62494521+mageven@users.noreply.github.com>
Date: Fri, 25 Sep 2020 15:48:28 +0530
Subject: [PATCH] Isolate more services to separate threads (#1573)

* Isolate more services to separate threads

* Fix DisplayServer

* Add explanation for vi services
---
 Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs             | 2 +-
 Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs | 2 +-
 Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs | 3 ++-
 Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs     | 3 ++-
 Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs      | 3 ++-
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
index a700b0ca90..4001cfddc5 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
@@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
         private HidAccelerometerParameters _accelerometerParams;
         private HidVibrationValue          _vibrationValue;
 
-        public IHidServer(ServiceCtx context)
+        public IHidServer(ServiceCtx context) : base(new ServerBase("HidServer"))
         {
             _xpadIdEvent                 = new KEvent(context.Device.System.KernelContext);
             _palmaOperationCompleteEvent = new KEvent(context.Device.System.KernelContext);
diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs
index 605cbbbd7a..743b9e13b1 100644
--- a/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs
@@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
         private IStaticServiceForPsc _inner;
         private TimePermissions      _permissions;
 
-        public IStaticServiceForGlue(ServiceCtx context, TimePermissions permissions)
+        public IStaticServiceForGlue(ServiceCtx context, TimePermissions permissions) : base(new ServerBase("TimeServer"))
         {
             _permissions = permissions;
             _inner       = new IStaticServiceForPsc(context, permissions);
diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs
index 3e853f02f4..22ffe65615 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs
@@ -5,7 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi
     [Service("vi:u")]
     class IApplicationRootService : IpcService
     {
-        public IApplicationRootService(ServiceCtx context) : base(new ServerBase("ViServer")) { }
+        // vi:u/m/s aren't on 3 separate threads but we can't put them together with the current ServerBase
+        public IApplicationRootService(ServiceCtx context) : base(new ServerBase("ViServerU")) { }
 
         [Command(0)]
         // GetDisplayService(u32) -> object<nn::visrv::sf::IApplicationDisplayService>
diff --git a/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs
index 31996ff1ed..a90690ea50 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs
@@ -5,7 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi
     [Service("vi:m")]
     class IManagerRootService : IpcService
     {
-        public IManagerRootService(ServiceCtx context) { }
+        // vi:u/m/s aren't on 3 separate threads but we can't put them together with the current ServerBase
+        public IManagerRootService(ServiceCtx context) : base(new ServerBase("ViServerM")) { }
 
         [Command(2)]
         // GetDisplayService(u32) -> object<nn::visrv::sf::IApplicationDisplayService>
diff --git a/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs
index 8d64e47548..65b2161306 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs
@@ -5,7 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi
     [Service("vi:s")]
     class ISystemRootService : IpcService
     {
-        public ISystemRootService(ServiceCtx context) { }
+        // vi:u/m/s aren't on 3 separate threads but we can't put them together with the current ServerBase
+        public ISystemRootService(ServiceCtx context) : base(new ServerBase("ViServerS")) { }
 
         [Command(1)]
         // GetDisplayService(u32) -> object<nn::visrv::sf::IApplicationDisplayService>