aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Horizon/ServiceTable.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Horizon/ServiceTable.cs')
-rw-r--r--Ryujinx.Horizon/ServiceTable.cs46
1 files changed, 41 insertions, 5 deletions
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<ServiceEntry> GetServices(HorizonOptions options)
+ private int _readyServices;
+ private int _totalServices;
+
+ private readonly ManualResetEvent _servicesReadyEvent = new(false);
+
+ public IEnumerable<ServiceEntry> GetServices(HorizonOptions options)
{
- List<ServiceEntry> entries = new List<ServiceEntry>();
+ List<ServiceEntry> entries = new();
void RegisterService<T>() where T : IService
{
- entries.Add(new ServiceEntry(T.Main, options));
+ entries.Add(new ServiceEntry(T.Main, this, options));
}
RegisterService<LmMain>();
+ RegisterService<PrepoMain>();
+
+ _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