From 550747eac6c0f6da14070c8b6d208bde6f1d1eb9 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Sun, 8 Jan 2023 13:13:39 +0100 Subject: Horizon: Impl Prepo, Fixes bugs, Clean things (#4220) * Horizon: Impl Prepo, Fixes bugs, Clean things * remove ToArray() * resultCode > status * Remove old services * Addresses gdkchan's comments and more cleanup * Addresses Gdkchan's feedback 2 * Reorganize services, make sure service are loaded before guest Co-Authored-By: gdkchan <5624669+gdkchan@users.noreply.github.com> * Create interfaces for lm and sm Co-authored-by: gdkchan <5624669+gdkchan@users.noreply.github.com> --- Ryujinx.Horizon/ServiceTable.cs | 46 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'Ryujinx.Horizon/ServiceTable.cs') diff --git a/Ryujinx.Horizon/ServiceTable.cs b/Ryujinx.Horizon/ServiceTable.cs index 933b6a59..2edc6ea1 100644 --- a/Ryujinx.Horizon/ServiceTable.cs +++ b/Ryujinx.Horizon/ServiceTable.cs @@ -1,22 +1,58 @@ using Ryujinx.Horizon.LogManager; +using Ryujinx.Horizon.Prepo; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.Horizon { - public static class ServiceTable + public class ServiceTable { - public static IEnumerable GetServices(HorizonOptions options) + private int _readyServices; + private int _totalServices; + + private readonly ManualResetEvent _servicesReadyEvent = new(false); + + public IEnumerable GetServices(HorizonOptions options) { - List entries = new List(); + List entries = new(); void RegisterService() where T : IService { - entries.Add(new ServiceEntry(T.Main, options)); + entries.Add(new ServiceEntry(T.Main, this, options)); } RegisterService(); + RegisterService(); + + _totalServices = entries.Count; return entries; } + + internal void SignalServiceReady() + { + if (Interlocked.Increment(ref _readyServices) == _totalServices) + { + _servicesReadyEvent.Set(); + } + } + + public void WaitServicesReady() + { + _servicesReadyEvent.WaitOne(); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + _servicesReadyEvent.Dispose(); + } + } + + public void Dispose() + { + Dispose(true); + } } -} +} \ No newline at end of file -- cgit v1.2.3