Replace "ManualResetEvent" for "ManualResetEventSlim"
This commit is contained in:
parent
0c3421973c
commit
f1ef552c02
30 changed files with 120 additions and 117 deletions
|
@ -55,7 +55,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
private readonly ulong _outerHeaderMagic;
|
private readonly ulong _outerHeaderMagic;
|
||||||
private readonly ulong _innerHeaderMagic;
|
private readonly ulong _innerHeaderMagic;
|
||||||
|
|
||||||
private readonly ManualResetEvent _waitEvent;
|
private readonly ManualResetEventSlim _waitEvent;
|
||||||
|
|
||||||
private readonly object _lock;
|
private readonly object _lock;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
_outerHeaderMagic = BinaryPrimitives.ReadUInt64LittleEndian(EncodingCache.UTF8NoBOM.GetBytes(OuterHeaderMagicString).AsSpan());
|
_outerHeaderMagic = BinaryPrimitives.ReadUInt64LittleEndian(EncodingCache.UTF8NoBOM.GetBytes(OuterHeaderMagicString).AsSpan());
|
||||||
_innerHeaderMagic = BinaryPrimitives.ReadUInt64LittleEndian(EncodingCache.UTF8NoBOM.GetBytes(InnerHeaderMagicString).AsSpan());
|
_innerHeaderMagic = BinaryPrimitives.ReadUInt64LittleEndian(EncodingCache.UTF8NoBOM.GetBytes(InnerHeaderMagicString).AsSpan());
|
||||||
|
|
||||||
_waitEvent = new ManualResetEvent(true);
|
_waitEvent = new ManualResetEventSlim(true);
|
||||||
|
|
||||||
_lock = new object();
|
_lock = new object();
|
||||||
|
|
||||||
|
@ -1123,7 +1123,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
private void Wait()
|
private void Wait()
|
||||||
{
|
{
|
||||||
_waitEvent.WaitOne();
|
_waitEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
private readonly ulong _outerHeaderMagic;
|
private readonly ulong _outerHeaderMagic;
|
||||||
|
|
||||||
private readonly ManualResetEvent _waitEvent;
|
private readonly ManualResetEventSlim _waitEvent;
|
||||||
|
|
||||||
private readonly object _lock;
|
private readonly object _lock;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
_outerHeaderMagic = BinaryPrimitives.ReadUInt64LittleEndian(EncodingCache.UTF8NoBOM.GetBytes(OuterHeaderMagicString).AsSpan());
|
_outerHeaderMagic = BinaryPrimitives.ReadUInt64LittleEndian(EncodingCache.UTF8NoBOM.GetBytes(OuterHeaderMagicString).AsSpan());
|
||||||
|
|
||||||
_waitEvent = new ManualResetEvent(true);
|
_waitEvent = new ManualResetEventSlim(true);
|
||||||
|
|
||||||
_lock = new object();
|
_lock = new object();
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
public void Wait()
|
public void Wait()
|
||||||
{
|
{
|
||||||
_waitEvent.WaitOne();
|
_waitEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||||
{
|
{
|
||||||
private readonly ALDevice _device;
|
private readonly ALDevice _device;
|
||||||
private readonly ALContext _context;
|
private readonly ALContext _context;
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEventSlim _updateRequiredEvent;
|
||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEventSlim _pauseEvent;
|
||||||
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
||||||
private bool _stillRunning;
|
private bool _stillRunning;
|
||||||
private readonly Thread _updaterThread;
|
private readonly Thread _updaterThread;
|
||||||
|
@ -43,8 +43,8 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||||
{
|
{
|
||||||
_device = ALC.OpenDevice("");
|
_device = ALC.OpenDevice("");
|
||||||
_context = ALC.CreateContext(_device, new ALContextAttributes());
|
_context = ALC.CreateContext(_device, new ALContextAttributes());
|
||||||
_updateRequiredEvent = new ManualResetEvent(false);
|
_updateRequiredEvent = new ManualResetEventSlim(false);
|
||||||
_pauseEvent = new ManualResetEvent(true);
|
_pauseEvent = new ManualResetEventSlim(true);
|
||||||
_sessions = new ConcurrentDictionary<OpenALHardwareDeviceSession, byte>();
|
_sessions = new ConcurrentDictionary<OpenALHardwareDeviceSession, byte>();
|
||||||
|
|
||||||
_stillRunning = true;
|
_stillRunning = true;
|
||||||
|
@ -106,12 +106,12 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||||
return _sessions.TryRemove(session, out _);
|
return _sessions.TryRemove(session, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEventSlim GetUpdateRequiredEvent()
|
||||||
{
|
{
|
||||||
return _updateRequiredEvent;
|
return _updateRequiredEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetPauseEvent()
|
public ManualResetEventSlim GetPauseEvent()
|
||||||
{
|
{
|
||||||
return _pauseEvent;
|
return _pauseEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
{
|
{
|
||||||
public class SDL2HardwareDeviceDriver : IHardwareDeviceDriver
|
public class SDL2HardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEventSlim _updateRequiredEvent;
|
||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEventSlim _pauseEvent;
|
||||||
private readonly ConcurrentDictionary<SDL2HardwareDeviceSession, byte> _sessions;
|
private readonly ConcurrentDictionary<SDL2HardwareDeviceSession, byte> _sessions;
|
||||||
|
|
||||||
private readonly bool _supportSurroundConfiguration;
|
private readonly bool _supportSurroundConfiguration;
|
||||||
|
@ -31,8 +31,8 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
|
|
||||||
public SDL2HardwareDeviceDriver()
|
public SDL2HardwareDeviceDriver()
|
||||||
{
|
{
|
||||||
_updateRequiredEvent = new ManualResetEvent(false);
|
_updateRequiredEvent = new ManualResetEventSlim(false);
|
||||||
_pauseEvent = new ManualResetEvent(true);
|
_pauseEvent = new ManualResetEventSlim(true);
|
||||||
_sessions = new ConcurrentDictionary<SDL2HardwareDeviceSession, byte>();
|
_sessions = new ConcurrentDictionary<SDL2HardwareDeviceSession, byte>();
|
||||||
|
|
||||||
SDL2Driver.Instance.Initialize();
|
SDL2Driver.Instance.Initialize();
|
||||||
|
@ -68,12 +68,12 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
return device != 0;
|
return device != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEventSlim GetUpdateRequiredEvent()
|
||||||
{
|
{
|
||||||
return _updateRequiredEvent;
|
return _updateRequiredEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetPauseEvent()
|
public ManualResetEventSlim GetPauseEvent()
|
||||||
{
|
{
|
||||||
return _pauseEvent;
|
return _pauseEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
private readonly ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
|
private readonly ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
|
||||||
private readonly DynamicRingBuffer _ringBuffer;
|
private readonly DynamicRingBuffer _ringBuffer;
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEventSlim _updateRequiredEvent;
|
||||||
private uint _outputStream;
|
private uint _outputStream;
|
||||||
private bool _hasSetupError;
|
private bool _hasSetupError;
|
||||||
private readonly SDL_AudioCallback _callbackDelegate;
|
private readonly SDL_AudioCallback _callbackDelegate;
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||||
{
|
{
|
||||||
private readonly SoundIoContext _audioContext;
|
private readonly SoundIoContext _audioContext;
|
||||||
private readonly SoundIoDeviceContext _audioDevice;
|
private readonly SoundIoDeviceContext _audioDevice;
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEventSlim _updateRequiredEvent;
|
||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEventSlim _pauseEvent;
|
||||||
private readonly ConcurrentDictionary<SoundIoHardwareDeviceSession, byte> _sessions;
|
private readonly ConcurrentDictionary<SoundIoHardwareDeviceSession, byte> _sessions;
|
||||||
private int _disposeState;
|
private int _disposeState;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||||
public SoundIoHardwareDeviceDriver()
|
public SoundIoHardwareDeviceDriver()
|
||||||
{
|
{
|
||||||
_audioContext = SoundIoContext.Create();
|
_audioContext = SoundIoContext.Create();
|
||||||
_updateRequiredEvent = new ManualResetEvent(false);
|
_updateRequiredEvent = new ManualResetEventSlim(false);
|
||||||
_pauseEvent = new ManualResetEvent(true);
|
_pauseEvent = new ManualResetEventSlim(true);
|
||||||
_sessions = new ConcurrentDictionary<SoundIoHardwareDeviceSession, byte>();
|
_sessions = new ConcurrentDictionary<SoundIoHardwareDeviceSession, byte>();
|
||||||
|
|
||||||
_audioContext.Connect();
|
_audioContext.Connect();
|
||||||
|
@ -131,12 +131,12 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||||
return fallback ? defaultAudioDevice : null;
|
return fallback ? defaultAudioDevice : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEventSlim GetUpdateRequiredEvent()
|
||||||
{
|
{
|
||||||
return _updateRequiredEvent;
|
return _updateRequiredEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetPauseEvent()
|
public ManualResetEventSlim GetPauseEvent()
|
||||||
{
|
{
|
||||||
return _pauseEvent;
|
return _pauseEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||||
private SoundIoOutStreamContext _outputStream;
|
private SoundIoOutStreamContext _outputStream;
|
||||||
private readonly DynamicRingBuffer _ringBuffer;
|
private readonly DynamicRingBuffer _ringBuffer;
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEventSlim _updateRequiredEvent;
|
||||||
private float _volume;
|
private float _volume;
|
||||||
private int _disposeState;
|
private int _disposeState;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.Audio
|
namespace Ryujinx.Audio
|
||||||
|
@ -16,7 +17,7 @@ namespace Ryujinx.Audio
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events signaled when the driver played audio buffers.
|
/// Events signaled when the driver played audio buffers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ManualResetEvent[] _updateRequiredEvents;
|
private readonly ManualResetEventSlim[] _updateRequiredEvents;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action to execute when the driver played audio buffers.
|
/// Action to execute when the driver played audio buffers.
|
||||||
|
@ -35,12 +36,12 @@ namespace Ryujinx.Audio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AudioManager()
|
public AudioManager()
|
||||||
{
|
{
|
||||||
_updateRequiredEvents = new ManualResetEvent[2];
|
_updateRequiredEvents = new ManualResetEventSlim[2];
|
||||||
_actions = new Action[2];
|
_actions = new Action[2];
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
|
|
||||||
// Termination event.
|
// Termination event.
|
||||||
_updateRequiredEvents[1] = new ManualResetEvent(false);
|
_updateRequiredEvents[1] = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
_workerThread = new Thread(Update)
|
_workerThread = new Thread(Update)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +69,7 @@ namespace Ryujinx.Audio
|
||||||
/// <param name="updatedRequiredEvent ">The driver event that will get signaled by the device driver when an audio buffer finished playing/being captured</param>
|
/// <param name="updatedRequiredEvent ">The driver event that will get signaled by the device driver when an audio buffer finished playing/being captured</param>
|
||||||
/// <param name="outputCallback">The callback to call when an audio buffer finished playing</param>
|
/// <param name="outputCallback">The callback to call when an audio buffer finished playing</param>
|
||||||
/// <param name="inputCallback">The callback to call when an audio buffer was captured</param>
|
/// <param name="inputCallback">The callback to call when an audio buffer was captured</param>
|
||||||
public void Initialize(ManualResetEvent updatedRequiredEvent, Action outputCallback, Action inputCallback)
|
public void Initialize(ManualResetEventSlim updatedRequiredEvent, Action outputCallback, Action inputCallback)
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +86,7 @@ namespace Ryujinx.Audio
|
||||||
{
|
{
|
||||||
while (_isRunning)
|
while (_isRunning)
|
||||||
{
|
{
|
||||||
int index = WaitHandle.WaitAny(_updateRequiredEvents);
|
int index = WaitHandle.WaitAny(_updateRequiredEvents.Select(x => x.WaitHandle).ToArray());
|
||||||
|
|
||||||
// Last index is here to indicate thread termination.
|
// Last index is here to indicate thread termination.
|
||||||
if (index + 1 == _updateRequiredEvents.Length)
|
if (index + 1 == _updateRequiredEvents.Length)
|
||||||
|
|
|
@ -33,12 +33,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
_realDriver.Dispose();
|
_realDriver.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEventSlim GetUpdateRequiredEvent()
|
||||||
{
|
{
|
||||||
return _realDriver.GetUpdateRequiredEvent();
|
return _realDriver.GetUpdateRequiredEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetPauseEvent()
|
public ManualResetEventSlim GetPauseEvent()
|
||||||
{
|
{
|
||||||
return _realDriver.GetPauseEvent();
|
return _realDriver.GetPauseEvent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
{
|
{
|
||||||
public class DummyHardwareDeviceDriver : IHardwareDeviceDriver
|
public class DummyHardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEventSlim _updateRequiredEvent;
|
||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEventSlim _pauseEvent;
|
||||||
|
|
||||||
public static bool IsSupported => true;
|
public static bool IsSupported => true;
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
|
|
||||||
public DummyHardwareDeviceDriver()
|
public DummyHardwareDeviceDriver()
|
||||||
{
|
{
|
||||||
_updateRequiredEvent = new ManualResetEvent(false);
|
_updateRequiredEvent = new ManualResetEventSlim(false);
|
||||||
_pauseEvent = new ManualResetEvent(true);
|
_pauseEvent = new ManualResetEventSlim(true);
|
||||||
|
|
||||||
Volume = 1f;
|
Volume = 1f;
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,12 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
return new DummyHardwareDeviceSessionInput(this, memoryManager);
|
return new DummyHardwareDeviceSessionInput(this, memoryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEventSlim GetUpdateRequiredEvent()
|
||||||
{
|
{
|
||||||
return _updateRequiredEvent;
|
return _updateRequiredEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetPauseEvent()
|
public ManualResetEventSlim GetPauseEvent()
|
||||||
{
|
{
|
||||||
return _pauseEvent;
|
return _pauseEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace Ryujinx.Audio.Integration
|
||||||
|
|
||||||
IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount);
|
IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount);
|
||||||
|
|
||||||
ManualResetEvent GetUpdateRequiredEvent();
|
ManualResetEventSlim GetUpdateRequiredEvent();
|
||||||
ManualResetEvent GetPauseEvent();
|
ManualResetEventSlim GetPauseEvent();
|
||||||
|
|
||||||
bool SupportsDirection(Direction direction);
|
bool SupportsDirection(Direction direction);
|
||||||
bool SupportsSampleRate(uint sampleRate);
|
bool SupportsSampleRate(uint sampleRate);
|
||||||
|
|
|
@ -36,13 +36,13 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
private long _lastTime;
|
private long _lastTime;
|
||||||
private long _playbackEnds;
|
private long _playbackEnds;
|
||||||
private readonly ManualResetEvent _event;
|
private readonly ManualResetEventSlim _event;
|
||||||
|
|
||||||
private ManualResetEvent _pauseEvent;
|
private ManualResetEventSlim _pauseEvent;
|
||||||
|
|
||||||
public AudioProcessor()
|
public AudioProcessor()
|
||||||
{
|
{
|
||||||
_event = new ManualResetEvent(false);
|
_event = new ManualResetEventSlim(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
|
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
|
||||||
|
@ -157,7 +157,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
while (timeNow < _lastTime + increment)
|
while (timeNow < _lastTime + increment)
|
||||||
{
|
{
|
||||||
_event.WaitOne(1);
|
_event.WaitHandle.WaitOne(1);
|
||||||
|
|
||||||
timeNow = PerformanceCounter.ElapsedNanoseconds;
|
timeNow = PerformanceCounter.ElapsedNanoseconds;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
_pauseEvent?.WaitOne();
|
_pauseEvent?.WaitHandle.WaitOne();
|
||||||
|
|
||||||
MailboxMessage message = _mailbox.ReceiveMessage();
|
MailboxMessage message = _mailbox.ReceiveMessage();
|
||||||
|
|
||||||
|
@ -204,10 +204,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
for (int i = 0; i < _sessionCommandList.Length; i++)
|
for (int i = 0; i < _sessionCommandList.Length; i++)
|
||||||
{
|
{
|
||||||
if (_sessionCommandList[i] != null)
|
RendererSession rendererSession = _sessionCommandList[i];
|
||||||
|
if (rendererSession != null)
|
||||||
{
|
{
|
||||||
_sessionCommandList[i].CommandList.Process(OutputDevices[i]);
|
rendererSession.CommandList.Process(OutputDevices[i]);
|
||||||
_sessionCommandList[i].CommandList.Dispose();
|
rendererSession.CommandList.Dispose();
|
||||||
_sessionCommandList[i] = null;
|
_sessionCommandList[i] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event signaled when the host emulation context is ready to be used by the gpu context.
|
/// Event signaled when the host emulation context is ready to be used by the gpu context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ManualResetEvent HostInitalized { get; }
|
public ManualResetEventSlim HostInitalized { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Host renderer.
|
/// Host renderer.
|
||||||
|
@ -107,7 +107,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
private long _modifiedSequence;
|
private long _modifiedSequence;
|
||||||
private readonly ulong _firstTimestamp;
|
private readonly ulong _firstTimestamp;
|
||||||
|
|
||||||
private readonly ManualResetEvent _gpuReadyEvent;
|
private readonly ManualResetEventSlim _gpuReadyEvent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the GPU emulation context.
|
/// Creates a new instance of the GPU emulation context.
|
||||||
|
@ -123,8 +123,8 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
|
|
||||||
Window = new Window(this);
|
Window = new Window(this);
|
||||||
|
|
||||||
HostInitalized = new ManualResetEvent(false);
|
HostInitalized = new ManualResetEventSlim(false);
|
||||||
_gpuReadyEvent = new ManualResetEvent(false);
|
_gpuReadyEvent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
SyncActions = new List<ISyncActionHandler>();
|
SyncActions = new List<ISyncActionHandler>();
|
||||||
SyncpointActions = new List<ISyncActionHandler>();
|
SyncpointActions = new List<ISyncActionHandler>();
|
||||||
|
@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void InitializeShaderCache(CancellationToken cancellationToken)
|
public void InitializeShaderCache(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
HostInitalized.WaitOne();
|
HostInitalized.WaitHandle.WaitOne();
|
||||||
|
|
||||||
foreach (var physicalMemory in PhysicalMemoryRegistry.Values)
|
foreach (var physicalMemory in PhysicalMemoryRegistry.Values)
|
||||||
{
|
{
|
||||||
|
@ -291,7 +291,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void WaitUntilGpuReady()
|
public void WaitUntilGpuReady()
|
||||||
{
|
{
|
||||||
_gpuReadyEvent.WaitOne();
|
_gpuReadyEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
|
||||||
timeout = TimeSpan.FromSeconds(1);
|
timeout = TimeSpan.FromSeconds(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
using ManualResetEvent waitEvent = new(false);
|
using ManualResetEventSlim waitEvent = new(false);
|
||||||
var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
|
var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
|
||||||
|
|
||||||
if (info == null)
|
if (info == null)
|
||||||
|
@ -94,7 +94,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool signaled = waitEvent.WaitOne(timeout);
|
bool signaled = waitEvent.WaitHandle.WaitOne(timeout);
|
||||||
|
|
||||||
if (!signaled && info != null)
|
if (!signaled && info != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Ryujinx.UI.Applet
|
||||||
|
|
||||||
public bool DisplayMessageDialog(string title, string message)
|
public bool DisplayMessageDialog(string title, string message)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool okPressed = false;
|
bool okPressed = false;
|
||||||
|
|
||||||
|
@ -76,14 +76,14 @@ namespace Ryujinx.UI.Applet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
return okPressed;
|
return okPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisplayInputDialog(SoftwareKeyboardUIArgs args, out string userText)
|
public bool DisplayInputDialog(SoftwareKeyboardUIArgs args, out string userText)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool okPressed = false;
|
bool okPressed = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
@ -129,7 +129,7 @@ namespace Ryujinx.UI.Applet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
((MainWindow)_parent).RendererWidget.NpadManager.UnblockInputUpdates();
|
((MainWindow)_parent).RendererWidget.NpadManager.UnblockInputUpdates();
|
||||||
|
|
||||||
userText = error ? null : inputText;
|
userText = error ? null : inputText;
|
||||||
|
@ -145,7 +145,7 @@ namespace Ryujinx.UI.Applet
|
||||||
|
|
||||||
public bool DisplayErrorAppletDialog(string title, string message, string[] buttons)
|
public bool DisplayErrorAppletDialog(string title, string message, string[] buttons)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool showDetails = false;
|
bool showDetails = false;
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ namespace Ryujinx.UI.Applet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
return showDetails;
|
return showDetails;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ namespace Ryujinx.UI
|
||||||
|
|
||||||
RendererWidget.Initialize(_emulationContext);
|
RendererWidget.Initialize(_emulationContext);
|
||||||
|
|
||||||
RendererWidget.WaitEvent.WaitOne();
|
RendererWidget.WaitEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
RendererWidget.Start();
|
RendererWidget.Start();
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.UI
|
||||||
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
|
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
|
||||||
private const float VolumeDelta = 0.05f;
|
private const float VolumeDelta = 0.05f;
|
||||||
|
|
||||||
public ManualResetEvent WaitEvent { get; set; }
|
public ManualResetEventSlim WaitEvent { get; set; }
|
||||||
public NpadManager NpadManager { get; }
|
public NpadManager NpadManager { get; }
|
||||||
public TouchScreenManager TouchScreenManager { get; }
|
public TouchScreenManager TouchScreenManager { get; }
|
||||||
public Switch Device { get; private set; }
|
public Switch Device { get; private set; }
|
||||||
|
@ -64,8 +64,8 @@ namespace Ryujinx.UI
|
||||||
|
|
||||||
private KeyboardHotkeyState _prevHotkeyState;
|
private KeyboardHotkeyState _prevHotkeyState;
|
||||||
|
|
||||||
private readonly ManualResetEvent _exitEvent;
|
private readonly ManualResetEventSlim _exitEvent;
|
||||||
private readonly ManualResetEvent _gpuDoneEvent;
|
private readonly ManualResetEventSlim _gpuDoneEvent;
|
||||||
|
|
||||||
private readonly CancellationTokenSource _gpuCancellationTokenSource;
|
private readonly CancellationTokenSource _gpuCancellationTokenSource;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace Ryujinx.UI
|
||||||
TouchScreenManager = _inputManager.CreateTouchScreenManager();
|
TouchScreenManager = _inputManager.CreateTouchScreenManager();
|
||||||
_keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
|
_keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
|
||||||
|
|
||||||
WaitEvent = new ManualResetEvent(false);
|
WaitEvent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
_glLogLevel = glLogLevel;
|
_glLogLevel = glLogLevel;
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ namespace Ryujinx.UI
|
||||||
| EventMask.KeyPressMask
|
| EventMask.KeyPressMask
|
||||||
| EventMask.KeyReleaseMask));
|
| EventMask.KeyReleaseMask));
|
||||||
|
|
||||||
_exitEvent = new ManualResetEvent(false);
|
_exitEvent = new ManualResetEventSlim(false);
|
||||||
_gpuDoneEvent = new ManualResetEvent(false);
|
_gpuDoneEvent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
_gpuCancellationTokenSource = new CancellationTokenSource();
|
_gpuCancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ namespace Ryujinx.UI
|
||||||
|
|
||||||
// NOTE: The render loop is allowed to stay alive until the renderer itself is disposed, as it may handle resource dispose.
|
// NOTE: The render loop is allowed to stay alive until the renderer itself is disposed, as it may handle resource dispose.
|
||||||
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
||||||
_gpuDoneEvent.WaitOne();
|
_gpuDoneEvent.WaitHandle.WaitOne();
|
||||||
_gpuDoneEvent.Dispose();
|
_gpuDoneEvent.Dispose();
|
||||||
nvidiaStutterWorkaround?.Join();
|
nvidiaStutterWorkaround?.Join();
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ namespace Ryujinx.UI
|
||||||
{
|
{
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
|
|
||||||
_exitEvent.WaitOne();
|
_exitEvent.WaitHandle.WaitOne();
|
||||||
_exitEvent.Dispose();
|
_exitEvent.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Ryujinx.UI.Windows
|
||||||
|
|
||||||
private Gdk.RGBA _selectedColor;
|
private Gdk.RGBA _selectedColor;
|
||||||
|
|
||||||
private readonly ManualResetEvent _avatarsPreloadingEvent = new(false);
|
private readonly ManualResetEventSlim _avatarsPreloadingEvent = new(false);
|
||||||
|
|
||||||
public UserProfilesManagerWindow(AccountManager accountManager, ContentManager contentManager, VirtualFileSystem virtualFileSystem) : base($"Ryujinx {Program.Version} - Manage User Profiles")
|
public UserProfilesManagerWindow(AccountManager accountManager, ContentManager contentManager, VirtualFileSystem virtualFileSystem) : base($"Ryujinx {Program.Version} - Manage User Profiles")
|
||||||
{
|
{
|
||||||
|
@ -256,7 +256,7 @@ namespace Ryujinx.UI.Windows
|
||||||
{
|
{
|
||||||
if (_contentManager.GetCurrentFirmwareVersion() != null)
|
if (_contentManager.GetCurrentFirmwareVersion() != null)
|
||||||
{
|
{
|
||||||
_avatarsPreloadingEvent.WaitOne();
|
_avatarsPreloadingEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectProfileImage();
|
SelectProfileImage();
|
||||||
|
|
|
@ -243,7 +243,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
// Wait until SM server thread is done with initialization,
|
// Wait until SM server thread is done with initialization,
|
||||||
// only then doing connections to SM is safe.
|
// only then doing connections to SM is safe.
|
||||||
SmServer.InitDone.WaitOne();
|
SmServer.InitDone.WaitHandle.WaitOne();
|
||||||
|
|
||||||
BsdServer = new ServerBase(KernelContext, "BsdServer");
|
BsdServer = new ServerBase(KernelContext, "BsdServer");
|
||||||
FsServer = new ServerBase(KernelContext, "FsServer");
|
FsServer = new ServerBase(KernelContext, "FsServer");
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
// even if they are not scheduled on guest cores.
|
// even if they are not scheduled on guest cores.
|
||||||
if (currentThread != null && !currentThread.IsSchedulable && currentThread.Context.Running)
|
if (currentThread != null && !currentThread.IsSchedulable && currentThread.Context.Running)
|
||||||
{
|
{
|
||||||
currentThread.SchedulerWaitEvent.WaitOne();
|
currentThread.SchedulerWaitEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,11 +312,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
if (nextThread == null)
|
if (nextThread == null)
|
||||||
{
|
{
|
||||||
ActivateIdleThread();
|
ActivateIdleThread();
|
||||||
currentThread.SchedulerWaitEvent.WaitOne();
|
currentThread.SchedulerWaitEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitHandle.SignalAndWait(nextThread.SchedulerWaitEvent, currentThread.SchedulerWaitEvent);
|
WaitHandle.SignalAndWait(nextThread.SchedulerWaitEvent.WaitHandle, currentThread.SchedulerWaitEvent.WaitHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,9 +18,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
public const int MaxWaitSyncObjects = 64;
|
public const int MaxWaitSyncObjects = 64;
|
||||||
|
|
||||||
private ManualResetEvent _schedulerWaitEvent;
|
private ManualResetEventSlim _schedulerWaitEvent;
|
||||||
|
|
||||||
public ManualResetEvent SchedulerWaitEvent => _schedulerWaitEvent;
|
public ManualResetEventSlim SchedulerWaitEvent => _schedulerWaitEvent;
|
||||||
|
|
||||||
public Thread HostThread { get; private set; }
|
public Thread HostThread { get; private set; }
|
||||||
|
|
||||||
|
@ -1232,7 +1232,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
{
|
{
|
||||||
if (_schedulerWaitEvent == null)
|
if (_schedulerWaitEvent == null)
|
||||||
{
|
{
|
||||||
var schedulerWaitEvent = new ManualResetEvent(false);
|
var schedulerWaitEvent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
if (Interlocked.Exchange(ref _schedulerWaitEvent, schedulerWaitEvent) == null)
|
if (Interlocked.Exchange(ref _schedulerWaitEvent, schedulerWaitEvent) == null)
|
||||||
{
|
{
|
||||||
|
@ -1247,7 +1247,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
private void ThreadStart()
|
private void ThreadStart()
|
||||||
{
|
{
|
||||||
_schedulerWaitEvent.WaitOne();
|
_schedulerWaitEvent.WaitHandle.WaitOne();
|
||||||
KernelStatic.SetKernelContext(KernelContext, this);
|
KernelStatic.SetKernelContext(KernelContext, this);
|
||||||
|
|
||||||
if (_customThreadStart != null)
|
if (_customThreadStart != null)
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
|
|
||||||
private int _isDisposed = 0;
|
private int _isDisposed = 0;
|
||||||
|
|
||||||
public ManualResetEvent InitDone { get; }
|
public ManualResetEventSlim InitDone { get; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public Func<IpcService> SmObjectFactory { get; }
|
public Func<IpcService> SmObjectFactory { get; }
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
_responseDataStream = MemoryStreamManager.Shared.GetStream();
|
_responseDataStream = MemoryStreamManager.Shared.GetStream();
|
||||||
_responseDataWriter = new BinaryWriter(_responseDataStream);
|
_responseDataWriter = new BinaryWriter(_responseDataStream);
|
||||||
|
|
||||||
InitDone = new ManualResetEvent(false);
|
InitDone = new ManualResetEventSlim(false);
|
||||||
Name = name;
|
Name = name;
|
||||||
SmObjectFactory = smObjectFactory;
|
SmObjectFactory = smObjectFactory;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
public void AddSessionObj(KServerSession serverSession, IpcService obj)
|
public void AddSessionObj(KServerSession serverSession, IpcService obj)
|
||||||
{
|
{
|
||||||
// Ensure that the sever loop is running.
|
// Ensure that the sever loop is running.
|
||||||
InitDone.WaitOne();
|
InitDone.WaitHandle.WaitOne();
|
||||||
|
|
||||||
_selfProcess.HandleTable.GenerateHandle(serverSession, out int serverSessionHandle);
|
_selfProcess.HandleTable.GenerateHandle(serverSession, out int serverSessionHandle);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
|
|
||||||
public bool Blocking { get => !_flags.HasFlag(EventFdFlags.NonBlocking); set => throw new NotSupportedException(); }
|
public bool Blocking { get => !_flags.HasFlag(EventFdFlags.NonBlocking); set => throw new NotSupportedException(); }
|
||||||
|
|
||||||
public ManualResetEvent WriteEvent { get; }
|
public ManualResetEventSlim WriteEvent { get; }
|
||||||
public ManualResetEvent ReadEvent { get; }
|
public ManualResetEventSlim ReadEvent { get; }
|
||||||
|
|
||||||
public EventFileDescriptor(ulong value, EventFdFlags flags)
|
public EventFileDescriptor(ulong value, EventFdFlags flags)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +27,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
_value = value;
|
_value = value;
|
||||||
_flags = flags;
|
_flags = flags;
|
||||||
|
|
||||||
WriteEvent = new ManualResetEvent(false);
|
WriteEvent = new ManualResetEventSlim(false);
|
||||||
ReadEvent = new ManualResetEvent(false);
|
ReadEvent = new ManualResetEventSlim(false);
|
||||||
UpdateEventStates();
|
UpdateEventStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
|
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
|
@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
{
|
{
|
||||||
updatedCount = 0;
|
updatedCount = 0;
|
||||||
|
|
||||||
List<ManualResetEvent> waiters = new();
|
List<ManualResetEventSlim> waiters = new();
|
||||||
|
|
||||||
for (int i = 0; i < events.Count; i++)
|
for (int i = 0; i < events.Count; i++)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = WaitHandle.WaitAny(waiters.ToArray(), timeoutMilliseconds);
|
int index = WaitHandle.WaitAny(waiters.Select(x => x.WaitHandle).ToArray(), timeoutMilliseconds);
|
||||||
|
|
||||||
if (index != WaitHandle.WaitTimeout)
|
if (index != WaitHandle.WaitTimeout)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
|
|
||||||
EventFileDescriptor socket = (EventFileDescriptor)evnt.FileDescriptor;
|
EventFileDescriptor socket = (EventFileDescriptor)evnt.FileDescriptor;
|
||||||
|
|
||||||
if (socket.ReadEvent.WaitOne(0))
|
if (socket.ReadEvent.WaitHandle.WaitOne(0))
|
||||||
{
|
{
|
||||||
if (evnt.Data.InputEvents.HasFlag(PollEventTypeMask.Input))
|
if (evnt.Data.InputEvents.HasFlag(PollEventTypeMask.Input))
|
||||||
{
|
{
|
||||||
|
@ -86,7 +87,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((evnt.Data.InputEvents.HasFlag(PollEventTypeMask.Output))
|
if ((evnt.Data.InputEvents.HasFlag(PollEventTypeMask.Output))
|
||||||
&& socket.WriteEvent.WaitOne(0))
|
&& socket.WriteEvent.WaitHandle.WaitOne(0))
|
||||||
{
|
{
|
||||||
outputEvents |= PollEventTypeMask.Output;
|
outputEvents |= PollEventTypeMask.Output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,8 @@ namespace Ryujinx.Headless.SDL2
|
||||||
private readonly Stopwatch _chrono;
|
private readonly Stopwatch _chrono;
|
||||||
private readonly long _ticksPerFrame;
|
private readonly long _ticksPerFrame;
|
||||||
private readonly CancellationTokenSource _gpuCancellationTokenSource;
|
private readonly CancellationTokenSource _gpuCancellationTokenSource;
|
||||||
private readonly ManualResetEvent _exitEvent;
|
private readonly ManualResetEventSlim _exitEvent;
|
||||||
private readonly ManualResetEvent _gpuDoneEvent;
|
private readonly ManualResetEventSlim _gpuDoneEvent;
|
||||||
|
|
||||||
private long _ticks;
|
private long _ticks;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
|
@ -102,8 +102,8 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_chrono = new Stopwatch();
|
_chrono = new Stopwatch();
|
||||||
_ticksPerFrame = Stopwatch.Frequency / TargetFps;
|
_ticksPerFrame = Stopwatch.Frequency / TargetFps;
|
||||||
_gpuCancellationTokenSource = new CancellationTokenSource();
|
_gpuCancellationTokenSource = new CancellationTokenSource();
|
||||||
_exitEvent = new ManualResetEvent(false);
|
_exitEvent = new ManualResetEventSlim(false);
|
||||||
_gpuDoneEvent = new ManualResetEvent(false);
|
_gpuDoneEvent = new ManualResetEventSlim(false);
|
||||||
_aspectRatio = aspectRatio;
|
_aspectRatio = aspectRatio;
|
||||||
_enableMouse = enableMouse;
|
_enableMouse = enableMouse;
|
||||||
HostUITheme = new HeadlessHostUiTheme();
|
HostUITheme = new HeadlessHostUiTheme();
|
||||||
|
@ -347,7 +347,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_isStopped = true;
|
_isStopped = true;
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
|
|
||||||
_exitEvent.WaitOne();
|
_exitEvent.WaitHandle.WaitOne();
|
||||||
_exitEvent.Dispose();
|
_exitEvent.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
// NOTE: The render loop is allowed to stay alive until the renderer itself is disposed, as it may handle resource dispose.
|
// NOTE: The render loop is allowed to stay alive until the renderer itself is disposed, as it may handle resource dispose.
|
||||||
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
||||||
_gpuDoneEvent.WaitOne();
|
_gpuDoneEvent.WaitHandle.WaitOne();
|
||||||
_gpuDoneEvent.Dispose();
|
_gpuDoneEvent.Dispose();
|
||||||
nvidiaStutterWorkaround?.Join();
|
nvidiaStutterWorkaround?.Join();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.Horizon
|
||||||
private int _readyServices;
|
private int _readyServices;
|
||||||
private int _totalServices;
|
private int _totalServices;
|
||||||
|
|
||||||
private readonly ManualResetEvent _servicesReadyEvent = new(false);
|
private readonly ManualResetEventSlim _servicesReadyEvent = new(false);
|
||||||
|
|
||||||
public IReader ArpReader { get; internal set; }
|
public IReader ArpReader { get; internal set; }
|
||||||
public IWriter ArpWriter { get; internal set; }
|
public IWriter ArpWriter { get; internal set; }
|
||||||
|
@ -74,7 +74,7 @@ namespace Ryujinx.Horizon
|
||||||
|
|
||||||
public void WaitServicesReady()
|
public void WaitServicesReady()
|
||||||
{
|
{
|
||||||
_servicesReadyEvent.WaitOne();
|
_servicesReadyEvent.WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace Ryujinx.Ava
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private bool _renderingStarted;
|
private bool _renderingStarted;
|
||||||
|
|
||||||
private readonly ManualResetEvent _gpuDoneEvent;
|
private readonly ManualResetEventSlim _gpuDoneEvent;
|
||||||
|
|
||||||
private IRenderer _renderer;
|
private IRenderer _renderer;
|
||||||
private readonly Thread _renderingThread;
|
private readonly Thread _renderingThread;
|
||||||
|
@ -207,7 +207,7 @@ namespace Ryujinx.Ava
|
||||||
ConfigurationState.Instance.Multiplayer.Mode.Event += UpdateMultiplayerModeState;
|
ConfigurationState.Instance.Multiplayer.Mode.Event += UpdateMultiplayerModeState;
|
||||||
|
|
||||||
_gpuCancellationTokenSource = new CancellationTokenSource();
|
_gpuCancellationTokenSource = new CancellationTokenSource();
|
||||||
_gpuDoneEvent = new ManualResetEvent(false);
|
_gpuDoneEvent = new ManualResetEventSlim(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TopLevel_PointerEnteredOrMoved(object sender, PointerEventArgs e)
|
private void TopLevel_PointerEnteredOrMoved(object sender, PointerEventArgs e)
|
||||||
|
@ -513,7 +513,7 @@ namespace Ryujinx.Ava
|
||||||
|
|
||||||
// NOTE: The render loop is allowed to stay alive until the renderer itself is disposed, as it may handle resource dispose.
|
// NOTE: The render loop is allowed to stay alive until the renderer itself is disposed, as it may handle resource dispose.
|
||||||
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
||||||
_gpuDoneEvent.WaitOne();
|
_gpuDoneEvent.WaitHandle.WaitOne();
|
||||||
_gpuDoneEvent.Dispose();
|
_gpuDoneEvent.Dispose();
|
||||||
|
|
||||||
DisplaySleep.Restore();
|
DisplaySleep.Restore();
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
|
|
||||||
public bool DisplayMessageDialog(ControllerAppletUIArgs args)
|
public bool DisplayMessageDialog(ControllerAppletUIArgs args)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool okPressed = false;
|
bool okPressed = false;
|
||||||
|
|
||||||
|
@ -44,14 +44,14 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
dialogCloseEvent.Set();
|
dialogCloseEvent.Set();
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
return okPressed;
|
return okPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisplayMessageDialog(string title, string message)
|
public bool DisplayMessageDialog(string title, string message)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool okPressed = false;
|
bool okPressed = false;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ManualResetEvent deferEvent = new(false);
|
ManualResetEventSlim deferEvent = new(false);
|
||||||
|
|
||||||
bool opened = false;
|
bool opened = false;
|
||||||
|
|
||||||
|
@ -105,14 +105,14 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
return okPressed;
|
return okPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisplayInputDialog(SoftwareKeyboardUIArgs args, out string userText)
|
public bool DisplayInputDialog(SoftwareKeyboardUIArgs args, out string userText)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool okPressed = false;
|
bool okPressed = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
@ -143,7 +143,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
_parent.ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
_parent.ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
||||||
|
|
||||||
userText = error ? null : inputText;
|
userText = error ? null : inputText;
|
||||||
|
@ -159,7 +159,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
|
|
||||||
public bool DisplayErrorAppletDialog(string title, string message, string[] buttons)
|
public bool DisplayErrorAppletDialog(string title, string message, string[] buttons)
|
||||||
{
|
{
|
||||||
ManualResetEvent dialogCloseEvent = new(false);
|
ManualResetEventSlim dialogCloseEvent = new(false);
|
||||||
|
|
||||||
bool showDetails = false;
|
bool showDetails = false;
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogCloseEvent.WaitOne();
|
dialogCloseEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
return showDetails;
|
return showDetails;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
string secondaryButton,
|
string secondaryButton,
|
||||||
string closeButton,
|
string closeButton,
|
||||||
UserResult primaryButtonResult = UserResult.Ok,
|
UserResult primaryButtonResult = UserResult.Ok,
|
||||||
ManualResetEvent deferResetEvent = null,
|
ManualResetEventSlim deferResetEvent = null,
|
||||||
TypedEventHandler<ContentDialog, ContentDialogButtonClickEventArgs> deferCloseAction = null)
|
TypedEventHandler<ContentDialog, ContentDialogButtonClickEventArgs> deferCloseAction = null)
|
||||||
{
|
{
|
||||||
UserResult result = UserResult.None;
|
UserResult result = UserResult.None;
|
||||||
|
@ -76,7 +76,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
string closeButton,
|
string closeButton,
|
||||||
int iconSymbol,
|
int iconSymbol,
|
||||||
UserResult primaryButtonResult = UserResult.Ok,
|
UserResult primaryButtonResult = UserResult.Ok,
|
||||||
ManualResetEvent deferResetEvent = null,
|
ManualResetEventSlim deferResetEvent = null,
|
||||||
TypedEventHandler<ContentDialog, ContentDialogButtonClickEventArgs> deferCloseAction = null)
|
TypedEventHandler<ContentDialog, ContentDialogButtonClickEventArgs> deferCloseAction = null)
|
||||||
{
|
{
|
||||||
Grid content = CreateTextDialogContent(primaryText, secondaryText, iconSymbol);
|
Grid content = CreateTextDialogContent(primaryText, secondaryText, iconSymbol);
|
||||||
|
@ -93,7 +93,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
string secondaryButton,
|
string secondaryButton,
|
||||||
string closeButton,
|
string closeButton,
|
||||||
int iconSymbol,
|
int iconSymbol,
|
||||||
ManualResetEvent deferResetEvent,
|
ManualResetEventSlim deferResetEvent,
|
||||||
Func<Window, Task> doWhileDeferred = null)
|
Func<Window, Task> doWhileDeferred = null)
|
||||||
{
|
{
|
||||||
bool startedDeferring = false;
|
bool startedDeferring = false;
|
||||||
|
@ -127,7 +127,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
|
||||||
_ = Task.Run(() =>
|
_ = Task.Run(() =>
|
||||||
{
|
{
|
||||||
deferResetEvent.WaitOne();
|
deferResetEvent.WaitHandle.WaitOne();
|
||||||
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue