2023-05-09 23:46:23 +02:00
|
|
|
using Ryujinx.Horizon.Bcat;
|
2023-01-04 23:15:45 +01:00
|
|
|
using Ryujinx.Horizon.LogManager;
|
2023-01-08 13:13:39 +01:00
|
|
|
using Ryujinx.Horizon.Prepo;
|
2023-01-04 23:15:45 +01:00
|
|
|
using System.Collections.Generic;
|
2023-01-08 13:13:39 +01:00
|
|
|
using System.Threading;
|
2023-01-04 23:15:45 +01:00
|
|
|
|
|
|
|
namespace Ryujinx.Horizon
|
|
|
|
{
|
2023-01-08 13:13:39 +01:00
|
|
|
public class ServiceTable
|
2023-01-04 23:15:45 +01:00
|
|
|
{
|
2023-01-08 13:13:39 +01:00
|
|
|
private int _readyServices;
|
|
|
|
private int _totalServices;
|
|
|
|
|
|
|
|
private readonly ManualResetEvent _servicesReadyEvent = new(false);
|
|
|
|
|
|
|
|
public IEnumerable<ServiceEntry> GetServices(HorizonOptions options)
|
2023-01-04 23:15:45 +01:00
|
|
|
{
|
2023-01-08 13:13:39 +01:00
|
|
|
List<ServiceEntry> entries = new();
|
2023-01-04 23:15:45 +01:00
|
|
|
|
|
|
|
void RegisterService<T>() where T : IService
|
|
|
|
{
|
2023-01-08 13:13:39 +01:00
|
|
|
entries.Add(new ServiceEntry(T.Main, this, options));
|
2023-01-04 23:15:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RegisterService<LmMain>();
|
2023-01-08 13:13:39 +01:00
|
|
|
RegisterService<PrepoMain>();
|
2023-05-09 23:46:23 +02:00
|
|
|
RegisterService<BcatMain>();
|
2023-01-08 13:13:39 +01:00
|
|
|
|
|
|
|
_totalServices = entries.Count;
|
2023-01-04 23:15:45 +01:00
|
|
|
|
|
|
|
return entries;
|
|
|
|
}
|
2023-01-08 13:13:39 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2023-01-04 23:15:45 +01:00
|
|
|
}
|
2023-07-01 12:42:10 +02:00
|
|
|
}
|