From 6c9565693fd87ae1af81ed63b5fbdde2a5dbecb8 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 22 Sep 2020 01:50:40 -0300 Subject: IPC refactor part 1: Use explicit separate threads to process requests (#1447) * Changes to allow explicit management of service threads * Remove now unused code * Remove ThreadCounter, its no longer needed * Allow and use separate server per service, also fix exit issues * New policy change: PTC version now uses PR number --- Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Sm') diff --git a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index 37f0a23c..d8f31faf 100644 --- a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -18,9 +18,11 @@ namespace Ryujinx.HLE.HOS.Services.Sm private ConcurrentDictionary _registeredServices; + private readonly ServerBase _commonServer; + private bool _isInitialized; - public IUserInterface(ServiceCtx context = null) + public IUserInterface(ServiceCtx context = null) : base(new ServerBase("SmServer")) { _registeredServices = new ConcurrentDictionary(); @@ -28,6 +30,8 @@ namespace Ryujinx.HLE.HOS.Services.Sm .SelectMany(type => type.GetCustomAttributes(typeof(ServiceAttribute), true) .Select(service => (((ServiceAttribute)service).Name, type))) .ToDictionary(service => service.Name, service => service.type); + + _commonServer = new ServerBase("CommonServer"); } public static void InitializePort(Horizon system) @@ -36,7 +40,9 @@ namespace Ryujinx.HLE.HOS.Services.Sm port.ClientPort.SetName("sm:"); - port.ClientPort.Service = new IUserInterface(); + IUserInterface smService = new IUserInterface(); + + port.ClientPort.Service = smService; } [Command(0)] @@ -81,8 +87,13 @@ namespace Ryujinx.HLE.HOS.Services.Sm { ServiceAttribute serviceAttribute = (ServiceAttribute)type.GetCustomAttributes(typeof(ServiceAttribute)).First(service => ((ServiceAttribute)service).Name == name); - session.ClientSession.Service = serviceAttribute.Parameter != null ? (IpcService)Activator.CreateInstance(type, context, serviceAttribute.Parameter) - : (IpcService)Activator.CreateInstance(type, context); + IpcService service = serviceAttribute.Parameter != null + ? (IpcService)Activator.CreateInstance(type, context, serviceAttribute.Parameter) + : (IpcService)Activator.CreateInstance(type, context); + + service.TrySetServer(_commonServer); + + session.ClientSession.Service = service; } else { -- cgit v1.2.3