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