b0b7843d5c
* mm: Migrate service in Horizon project This PR migrate the `mm:u` service to the Horizon project, things were checked by some RE aswell, that's why some vars are renamed, the logic should be the same as before. Tests are welcome. * Lock _sessionList instead * Fix comment * Fix Session fields order
62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using Ryujinx.Horizon.Bcat;
|
|
using Ryujinx.Horizon.LogManager;
|
|
using Ryujinx.Horizon.MmNv;
|
|
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>();
|
|
RegisterService<BcatMain>();
|
|
RegisterService<MmNvMain>();
|
|
|
|
_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);
|
|
}
|
|
}
|
|
}
|