diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.Horizon/ServiceTable.cs | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.Horizon/ServiceTable.cs')
| -rw-r--r-- | src/Ryujinx.Horizon/ServiceTable.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Ryujinx.Horizon/ServiceTable.cs b/src/Ryujinx.Horizon/ServiceTable.cs new file mode 100644 index 00000000..2edc6ea1 --- /dev/null +++ b/src/Ryujinx.Horizon/ServiceTable.cs @@ -0,0 +1,58 @@ +using Ryujinx.Horizon.LogManager; +using Ryujinx.Horizon.Prepo; +using System.Collections.Generic; +using System.Threading; + +namespace Ryujinx.Horizon +{ + public class ServiceTable + { + private int _readyServices; + private int _totalServices; + + private readonly ManualResetEvent _servicesReadyEvent = new(false); + + public IEnumerable<ServiceEntry> GetServices(HorizonOptions options) + { + List<ServiceEntry> entries = new(); + + void RegisterService<T>() where T : IService + { + 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 |
