Use the new Lock type where applicable

This commit is contained in:
Isaac Marovitz 2024-07-23 12:40:28 +01:00 committed by Isaac Marovitz
parent 4928551393
commit e42ae95895
54 changed files with 109 additions and 76 deletions

View file

@ -1,6 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<LangVersion>preview</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageVersion Include="Avalonia" Version="11.0.10" /> <PackageVersion Include="Avalonia" Version="11.0.10" />

View file

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using System.Threading;
namespace ARMeilleure.Translation.Cache namespace ARMeilleure.Translation.Cache
{ {
@ -26,7 +27,7 @@ namespace ARMeilleure.Translation.Cache
private static readonly List<CacheEntry> _cacheEntries = new(); private static readonly List<CacheEntry> _cacheEntries = new();
private static readonly object _lock = new(); private static readonly Lock _lock = new();
private static bool _initialized; private static bool _initialized;
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]

View file

@ -57,7 +57,7 @@ namespace ARMeilleure.Translation.PTC
private readonly ManualResetEvent _waitEvent; private readonly ManualResetEvent _waitEvent;
private readonly object _lock; private readonly Lock _lock;
private bool _disposed; private bool _disposed;
@ -87,7 +87,7 @@ namespace ARMeilleure.Translation.PTC
_waitEvent = new ManualResetEvent(true); _waitEvent = new ManualResetEvent(true);
_lock = new object(); _lock = new Lock();
_disposed = false; _disposed = false;

View file

@ -41,7 +41,7 @@ namespace ARMeilleure.Translation.PTC
private readonly ManualResetEvent _waitEvent; private readonly ManualResetEvent _waitEvent;
private readonly object _lock; private readonly Lock _lock;
private bool _disposed; private bool _disposed;
@ -65,7 +65,7 @@ namespace ARMeilleure.Translation.PTC
_waitEvent = new ManualResetEvent(true); _waitEvent = new ManualResetEvent(true);
_lock = new object(); _lock = new Lock();
_disposed = false; _disposed = false;

View file

@ -5,6 +5,7 @@ using Ryujinx.Memory;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Threading;
namespace Ryujinx.Audio.Backends.OpenAL namespace Ryujinx.Audio.Backends.OpenAL
{ {
@ -18,7 +19,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
private ulong _playedSampleCount; private ulong _playedSampleCount;
private float _volume; private float _volume;
private readonly object _lock = new(); private readonly Lock _lock = new();
public OpenALHardwareDeviceSession(OpenALHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount) public OpenALHardwareDeviceSession(OpenALHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
{ {

View file

@ -11,7 +11,7 @@ namespace Ryujinx.Audio
/// <summary> /// <summary>
/// Lock used to control the waiters registration. /// Lock used to control the waiters registration.
/// </summary> /// </summary>
private readonly object _lock = new(); private readonly Lock _lock = new();
/// <summary> /// <summary>
/// Events signaled when the driver played audio buffers. /// Events signaled when the driver played audio buffers.

View file

@ -2,6 +2,7 @@ using Ryujinx.Common;
using Ryujinx.Common.Memory; using Ryujinx.Common.Memory;
using System; using System;
using System.Buffers; using System.Buffers;
using System.Threading;
namespace Ryujinx.Audio.Backends.Common namespace Ryujinx.Audio.Backends.Common
{ {
@ -12,7 +13,7 @@ namespace Ryujinx.Audio.Backends.Common
{ {
private const int RingBufferAlignment = 2048; private const int RingBufferAlignment = 2048;
private readonly object _lock = new(); private readonly Lock _lock = new();
private MemoryOwner<byte> _bufferOwner; private MemoryOwner<byte> _bufferOwner;
private Memory<byte> _buffer; private Memory<byte> _buffer;

View file

@ -14,12 +14,12 @@ namespace Ryujinx.Audio.Input
/// </summary> /// </summary>
public class AudioInputManager : IDisposable public class AudioInputManager : IDisposable
{ {
private readonly object _lock = new(); private readonly Lock _lock = new();
/// <summary> /// <summary>
/// Lock used for session allocation. /// Lock used for session allocation.
/// </summary> /// </summary>
private readonly object _sessionLock = new(); private readonly Lock _sessionLock = new();
/// <summary> /// <summary>
/// The session ids allocation table. /// The session ids allocation table.

View file

@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Input
/// <summary> /// <summary>
/// The lock of the parent. /// The lock of the parent.
/// </summary> /// </summary>
private readonly object _parentLock; private readonly Lock _parentLock;
/// <summary> /// <summary>
/// The dispose state. /// The dispose state.
@ -62,7 +62,7 @@ namespace Ryujinx.Audio.Input
/// <param name="parentLock">The lock of the manager</param> /// <param name="parentLock">The lock of the manager</param>
/// <param name="deviceSession">The hardware device session</param> /// <param name="deviceSession">The hardware device session</param>
/// <param name="bufferEvent">The buffer release event of the audio input</param> /// <param name="bufferEvent">The buffer release event of the audio input</param>
public AudioInputSystem(AudioInputManager manager, object parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent) public AudioInputSystem(AudioInputManager manager, Lock parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent)
{ {
_manager = manager; _manager = manager;
_parentLock = parentLock; _parentLock = parentLock;

View file

@ -14,12 +14,12 @@ namespace Ryujinx.Audio.Output
/// </summary> /// </summary>
public class AudioOutputManager : IDisposable public class AudioOutputManager : IDisposable
{ {
private readonly object _lock = new(); private readonly Lock _lock = new();
/// <summary> /// <summary>
/// Lock used for session allocation. /// Lock used for session allocation.
/// </summary> /// </summary>
private readonly object _sessionLock = new(); private readonly Lock _sessionLock = new();
/// <summary> /// <summary>
/// The session ids allocation table. /// The session ids allocation table.

View file

@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Output
/// <summary> /// <summary>
/// THe lock of the parent. /// THe lock of the parent.
/// </summary> /// </summary>
private readonly object _parentLock; private readonly Lock _parentLock;
/// <summary> /// <summary>
/// The dispose state. /// The dispose state.
@ -62,7 +62,7 @@ namespace Ryujinx.Audio.Output
/// <param name="parentLock">The lock of the manager</param> /// <param name="parentLock">The lock of the manager</param>
/// <param name="deviceSession">The hardware device session</param> /// <param name="deviceSession">The hardware device session</param>
/// <param name="bufferEvent">The buffer release event of the audio output</param> /// <param name="bufferEvent">The buffer release event of the audio output</param>
public AudioOutputSystem(AudioOutputManager manager, object parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent) public AudioOutputSystem(AudioOutputManager manager, Lock parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent)
{ {
_manager = manager; _manager = manager;
_parentLock = parentLock; _parentLock = parentLock;

View file

@ -26,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Server
{ {
public class AudioRenderSystem : IDisposable public class AudioRenderSystem : IDisposable
{ {
private readonly object _lock = new(); private readonly Lock _lock = new();
private AudioRendererRenderingDevice _renderingDevice; private AudioRendererRenderingDevice _renderingDevice;
private AudioRendererExecutionMode _executionMode; private AudioRendererExecutionMode _executionMode;

View file

@ -19,12 +19,12 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary> /// <summary>
/// Lock used for session allocation. /// Lock used for session allocation.
/// </summary> /// </summary>
private readonly object _sessionLock = new(); private readonly Lock _sessionLock = new();
/// <summary> /// <summary>
/// Lock used to control the <see cref="AudioProcessor"/> running state. /// Lock used to control the <see cref="AudioProcessor"/> running state.
/// </summary> /// </summary>
private readonly object _audioProcessorLock = new(); private readonly Lock _audioProcessorLock = new();
/// <summary> /// <summary>
/// The session ids allocation table. /// The session ids allocation table.

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Threading;
namespace Ryujinx.Audio.Renderer.Server.Upsampler namespace Ryujinx.Audio.Renderer.Server.Upsampler
{ {
@ -16,7 +17,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
/// <summary> /// <summary>
/// Global lock of the object. /// Global lock of the object.
/// </summary> /// </summary>
private readonly object _lock = new(); private readonly Lock _lock = new();
/// <summary> /// <summary>
/// The upsamplers instances. /// The upsamplers instances.

View file

@ -124,7 +124,7 @@ namespace Ryujinx.Common.PreciseSleep
} }
} }
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly List<NanosleepThread> _threads = new(); private readonly List<NanosleepThread> _threads = new();
private readonly List<NanosleepThread> _active = new(); private readonly List<NanosleepThread> _active = new();
private readonly Stack<NanosleepThread> _free = new(); private readonly Stack<NanosleepThread> _free = new();

View file

@ -50,7 +50,7 @@ namespace Ryujinx.Common.SystemInterop
private long _lastTicks = PerformanceCounter.ElapsedTicks; private long _lastTicks = PerformanceCounter.ElapsedTicks;
private long _lastId; private long _lastId;
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly List<WaitingObject> _waitingObjects = new(); private readonly List<WaitingObject> _waitingObjects = new();
private WindowsGranularTimer() private WindowsGranularTimer()

View file

@ -1,6 +1,7 @@
using Ryujinx.Memory; using Ryujinx.Memory;
using System; using System;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using System.Threading;
namespace Ryujinx.Cpu.AppleHv namespace Ryujinx.Cpu.AppleHv
{ {
@ -12,7 +13,7 @@ namespace Ryujinx.Cpu.AppleHv
private static int _addressSpaces; private static int _addressSpaces;
private static HvIpaAllocator _ipaAllocator; private static HvIpaAllocator _ipaAllocator;
private static readonly object _lock = new(); private static readonly Lock _lock = new();
public static (ulong, HvIpaAllocator) CreateAddressSpace(MemoryBlock block) public static (ulong, HvIpaAllocator) CreateAddressSpace(MemoryBlock block)
{ {

View file

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using System.Threading;
namespace Ryujinx.Cpu.LightningJit.Cache namespace Ryujinx.Cpu.LightningJit.Cache
{ {
@ -23,7 +24,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private static readonly List<CacheEntry> _cacheEntries = new(); private static readonly List<CacheEntry> _cacheEntries = new();
private static readonly object _lock = new(); private static readonly Lock _lock = new();
private static bool _initialized; private static bool _initialized;
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]

View file

@ -4,6 +4,7 @@ using Ryujinx.Memory;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Threading;
namespace Ryujinx.Cpu.LightningJit.Cache namespace Ryujinx.Cpu.LightningJit.Cache
{ {
@ -104,7 +105,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private readonly MemoryCache _sharedCache; private readonly MemoryCache _sharedCache;
private readonly MemoryCache _localCache; private readonly MemoryCache _localCache;
private readonly PageAlignedRangeList _pendingMap; private readonly PageAlignedRangeList _pendingMap;
private readonly object _lock; private readonly Lock _lock;
class ThreadLocalCacheEntry class ThreadLocalCacheEntry
{ {

View file

@ -5,6 +5,7 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.Cpu.Signal namespace Ryujinx.Cpu.Signal
{ {
@ -59,7 +60,7 @@ namespace Ryujinx.Cpu.Signal
private static MemoryBlock _codeBlock; private static MemoryBlock _codeBlock;
private static readonly object _lock = new(); private static readonly Lock _lock = new();
private static bool _initialized; private static bool _initialized;
static NativeSignalHandler() static NativeSignalHandler()

View file

@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
private int _refConsumerPtr; private int _refConsumerPtr;
private Action _interruptAction; private Action _interruptAction;
private readonly object _interruptLock = new(); private readonly Lock _interruptLock = new();
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured; public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;

View file

@ -2,6 +2,7 @@ using Ryujinx.Common.Pools;
using Ryujinx.Memory.Range; using Ryujinx.Memory.Range;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Memory namespace Ryujinx.Graphics.Gpu.Memory
{ {
@ -76,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private BufferMigration _source; private BufferMigration _source;
private BufferModifiedRangeList _migrationTarget; private BufferModifiedRangeList _migrationTarget;
private readonly object _lock = new(); private readonly Lock _lock = new();
/// <summary> /// <summary>
/// Whether the modified range list has any entries or not. /// Whether the modified range list has any entries or not.

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
private ulong _accumulatedCounter; private ulong _accumulatedCounter;
private int _waiterCount; private int _waiterCount;
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly Queue<BufferedQuery> _queryPool; private readonly Queue<BufferedQuery> _queryPool;
private readonly AutoResetEvent _queuedEvent = new(false); private readonly AutoResetEvent _queuedEvent = new(false);

View file

@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
private bool _hostAccessReserved = false; private bool _hostAccessReserved = false;
private int _refCount = 1; // Starts with a reference from the counter queue. private int _refCount = 1; // Starts with a reference from the counter queue.
private readonly object _lock = new(); private readonly Lock _lock = new();
private ulong _result = ulong.MaxValue; private ulong _result = ulong.MaxValue;
private double _divisor = 1f; private double _divisor = 1f;

View file

@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.OpenGL.Image; using Ryujinx.Graphics.OpenGL.Image;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Graphics.OpenGL namespace Ryujinx.Graphics.OpenGL
{ {
@ -19,7 +20,7 @@ namespace Ryujinx.Graphics.OpenGL
{ {
private const int DisposedLiveFrames = 2; private const int DisposedLiveFrames = 2;
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly Dictionary<TextureCreateInfo, List<DisposedTexture>> _textures = new(); private readonly Dictionary<TextureCreateInfo, List<DisposedTexture>> _textures = new();
/// <summary> /// <summary>

View file

@ -4,6 +4,7 @@ using Ryujinx.Graphics.Shader.StructuredIr;
using Ryujinx.Graphics.Shader.Translation; using Ryujinx.Graphics.Shader.Translation;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using static Spv.Specification; using static Spv.Specification;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
@ -19,13 +20,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
private const int GeneratorPoolCount = 1; private const int GeneratorPoolCount = 1;
private static readonly ObjectPool<SpvInstructionPool> _instructionPool; private static readonly ObjectPool<SpvInstructionPool> _instructionPool;
private static readonly ObjectPool<SpvLiteralIntegerPool> _integerPool; private static readonly ObjectPool<SpvLiteralIntegerPool> _integerPool;
private static readonly object _poolLock; private static readonly Lock _poolLock;
static SpirvGenerator() static SpirvGenerator()
{ {
_instructionPool = new(() => new SpvInstructionPool(), GeneratorPoolCount); _instructionPool = new(() => new SpvInstructionPool(), GeneratorPoolCount);
_integerPool = new(() => new SpvLiteralIntegerPool(), GeneratorPoolCount); _integerPool = new(() => new SpvLiteralIntegerPool(), GeneratorPoolCount);
_poolLock = new object(); _poolLock = new Lock();
} }
private const HelperFunctionsMask NeedsInvocationIdMask = HelperFunctionsMask.SwizzleAdd; private const HelperFunctionsMask NeedsInvocationIdMask = HelperFunctionsMask.SwizzleAdd;

View file

@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
bool useBackground = _gd.BackgroundQueue.Handle != 0 && _gd.Vendor != Vendor.Amd; bool useBackground = _gd.BackgroundQueue.Handle != 0 && _gd.Vendor != Vendor.Amd;
Queue queue = useBackground ? _gd.BackgroundQueue : _gd.Queue; Queue queue = useBackground ? _gd.BackgroundQueue : _gd.Queue;
object queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock; Lock queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock;
lock (queueLock) lock (queueLock)
{ {

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Vulkan
private readonly Vk _api; private readonly Vk _api;
private readonly Device _device; private readonly Device _device;
private readonly Queue _queue; private readonly Queue _queue;
private readonly object _queueLock; private readonly Lock _queueLock;
private readonly bool _concurrentFenceWaitUnsupported; private readonly bool _concurrentFenceWaitUnsupported;
private readonly CommandPool _pool; private readonly CommandPool _pool;
private readonly Thread _owner; private readonly Thread _owner;
@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Vulkan
Vk api, Vk api,
Device device, Device device,
Queue queue, Queue queue,
object queueLock, Lock queueLock,
uint queueFamilyIndex, uint queueFamilyIndex,
bool concurrentFenceWaitUnsupported, bool concurrentFenceWaitUnsupported,
bool isLight = false) bool isLight = false)

View file

@ -5,6 +5,7 @@ using Silk.NET.Vulkan;
using Silk.NET.Vulkan.Extensions.EXT; using Silk.NET.Vulkan.Extensions.EXT;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Graphics.Vulkan namespace Ryujinx.Graphics.Vulkan
{ {
@ -31,7 +32,7 @@ namespace Ryujinx.Graphics.Vulkan
private readonly Vk _api; private readonly Vk _api;
private readonly ExtExternalMemoryHost _hostMemoryApi; private readonly ExtExternalMemoryHost _hostMemoryApi;
private readonly Device _device; private readonly Device _device;
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly List<HostMemoryAllocation> _allocations; private readonly List<HostMemoryAllocation> _allocations;
private readonly IntervalTree<ulong, HostMemoryAllocation> _allocationTree; private readonly IntervalTree<ulong, HostMemoryAllocation> _allocationTree;

View file

@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
private ulong _accumulatedCounter; private ulong _accumulatedCounter;
private int _waiterCount; private int _waiterCount;
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly Queue<BufferedQuery> _queryPool; private readonly Queue<BufferedQuery> _queryPool;
private readonly AutoResetEvent _queuedEvent = new(false); private readonly AutoResetEvent _queuedEvent = new(false);

View file

@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
private bool _hostAccessReserved; private bool _hostAccessReserved;
private int _refCount = 1; // Starts with a reference from the counter queue. private int _refCount = 1; // Starts with a reference from the counter queue.
private readonly object _lock = new(); private readonly Lock _lock = new();
private ulong _result = ulong.MaxValue; private ulong _result = ulong.MaxValue;
private double _divisor = 1f; private double _divisor = 1f;

View file

@ -5,6 +5,7 @@ using shaderc;
using Silk.NET.Vulkan; using Silk.NET.Vulkan;
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Ryujinx.Graphics.Vulkan namespace Ryujinx.Graphics.Vulkan
@ -13,7 +14,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
// The shaderc.net dependency's Options constructor and dispose are not thread safe. // The shaderc.net dependency's Options constructor and dispose are not thread safe.
// Take this lock when using them. // Take this lock when using them.
private static readonly object _shaderOptionsLock = new(); private static readonly Lock _shaderOptionsLock = new();
private static readonly IntPtr _ptrMainEntryPointName = Marshal.StringToHGlobalAnsi("main"); private static readonly IntPtr _ptrMainEntryPointName = Marshal.StringToHGlobalAnsi("main");

View file

@ -11,6 +11,7 @@ using Silk.NET.Vulkan.Extensions.KHR;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using Format = Ryujinx.Graphics.GAL.Format; using Format = Ryujinx.Graphics.GAL.Format;
using PrimitiveTopology = Ryujinx.Graphics.GAL.PrimitiveTopology; using PrimitiveTopology = Ryujinx.Graphics.GAL.PrimitiveTopology;
using SamplerCreateInfo = Ryujinx.Graphics.GAL.SamplerCreateInfo; using SamplerCreateInfo = Ryujinx.Graphics.GAL.SamplerCreateInfo;
@ -42,8 +43,8 @@ namespace Ryujinx.Graphics.Vulkan
internal uint QueueFamilyIndex { get; private set; } internal uint QueueFamilyIndex { get; private set; }
internal Queue Queue { get; private set; } internal Queue Queue { get; private set; }
internal Queue BackgroundQueue { get; private set; } internal Queue BackgroundQueue { get; private set; }
internal object BackgroundQueueLock { get; private set; } internal Lock BackgroundQueueLock { get; private set; }
internal object QueueLock { get; private set; } internal Lock QueueLock { get; private set; }
internal MemoryAllocator MemoryAllocator { get; private set; } internal MemoryAllocator MemoryAllocator { get; private set; }
internal HostMemoryAllocator HostMemoryAllocator { get; private set; } internal HostMemoryAllocator HostMemoryAllocator { get; private set; }
@ -153,7 +154,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
Api.GetDeviceQueue(_device, queueFamilyIndex, 1, out var backgroundQueue); Api.GetDeviceQueue(_device, queueFamilyIndex, 1, out var backgroundQueue);
BackgroundQueue = backgroundQueue; BackgroundQueue = backgroundQueue;
BackgroundQueueLock = new object(); BackgroundQueueLock = new Lock();
} }
PhysicalDeviceProperties2 properties2 = new() PhysicalDeviceProperties2 properties2 = new()
@ -458,7 +459,7 @@ namespace Ryujinx.Graphics.Vulkan
Api.GetDeviceQueue(_device, queueFamilyIndex, 0, out var queue); Api.GetDeviceQueue(_device, queueFamilyIndex, 0, out var queue);
Queue = queue; Queue = queue;
QueueLock = new object(); QueueLock = new Lock();
LoadFeatures(maxQueueCount, queueFamilyIndex); LoadFeatures(maxQueueCount, queueFamilyIndex);

View file

@ -3,6 +3,7 @@ using Ryujinx.Common.Configuration.Hid.Keyboard;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Threading;
using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; using ConfigKey = Ryujinx.Common.Configuration.Hid.Key;
namespace Ryujinx.Input.GTK3 namespace Ryujinx.Input.GTK3
@ -21,7 +22,7 @@ namespace Ryujinx.Input.GTK3
} }
} }
private readonly object _userMappingLock = new(); private readonly Lock _userMappingLock = new();
private readonly GTK3KeyboardDriver _driver; private readonly GTK3KeyboardDriver _driver;
private StandardKeyboardInputConfig _configuration; private StandardKeyboardInputConfig _configuration;

View file

@ -21,6 +21,7 @@ using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using Path = System.IO.Path; using Path = System.IO.Path;
namespace Ryujinx.HLE.FileSystem namespace Ryujinx.HLE.FileSystem
@ -54,7 +55,7 @@ namespace Ryujinx.HLE.FileSystem
private readonly VirtualFileSystem _virtualFileSystem; private readonly VirtualFileSystem _virtualFileSystem;
private readonly object _lock = new(); private readonly Lock _lock = new();
public ContentManager(VirtualFileSystem virtualFileSystem) public ContentManager(VirtualFileSystem virtualFileSystem)
{ {

View file

@ -14,6 +14,7 @@ using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading;
namespace Ryujinx.HLE.HOS.Applets namespace Ryujinx.HLE.HOS.Applets
{ {
@ -62,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Applets
private bool _canAcceptController = false; private bool _canAcceptController = false;
private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard; private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard;
private readonly object _lock = new(); private readonly Lock _lock = new();
public event EventHandler AppletStateChanged; public event EventHandler AppletStateChanged;

View file

@ -11,6 +11,7 @@ using System.IO;
using System.Numerics; using System.Numerics;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
{ {
@ -26,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
const string CancelText = "Cancel"; const string CancelText = "Cancel";
const string ControllerToggleText = "Toggle input"; const string ControllerToggleText = "Toggle input";
private readonly object _bufferLock = new(); private readonly Lock _bufferLock = new();
private RenderingSurfaceInfo _surfaceInfo = null; private RenderingSurfaceInfo _surfaceInfo = null;
private Image<Argb32> _surface = null; private Image<Argb32> _surface = null;

View file

@ -27,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
private TRef<bool> _cancelled = null; private TRef<bool> _cancelled = null;
private Thread _thread = null; private Thread _thread = null;
private readonly object _lock = new(); private readonly Lock _lock = new();
public bool IsRunning public bool IsRunning
{ {

View file

@ -1,5 +1,6 @@
using Ryujinx.Common.Memory; using Ryujinx.Common.Memory;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.HLE.HOS.Services.Ldn.Types namespace Ryujinx.HLE.HOS.Services.Ldn.Types
{ {
@ -12,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.Types
static class NodeLatestUpdateHelper static class NodeLatestUpdateHelper
{ {
private static readonly object _lock = new(); private static readonly Lock _lock = new();
public static void CalculateLatestUpdate(this Array8<NodeLatestUpdate> array, Array8<NodeInfo> beforeNodes, Array8<NodeInfo> afterNodes) public static void CalculateLatestUpdate(this Array8<NodeLatestUpdate> array, Array8<NodeInfo> beforeNodes, Array8<NodeInfo> afterNodes)
{ {

View file

@ -1,5 +1,7 @@
using Ryujinx.Common; using Ryujinx.Common;
using System.Threading;
using System.Timers; using System.Timers;
using Timer = System.Timers.Timer;
namespace Ryujinx.HLE namespace Ryujinx.HLE
{ {
@ -20,8 +22,8 @@ namespace Ryujinx.HLE
private readonly long[] _framesRendered; private readonly long[] _framesRendered;
private readonly double[] _percentTime; private readonly double[] _percentTime;
private readonly object[] _frameLock; private readonly Lock[] _frameLock;
private readonly object[] _percentLock; private readonly Lock[] _percentLock;
private readonly double _ticksToSeconds; private readonly double _ticksToSeconds;
@ -41,8 +43,8 @@ namespace Ryujinx.HLE
_framesRendered = new long[1]; _framesRendered = new long[1];
_percentTime = new double[1]; _percentTime = new double[1];
_frameLock = new[] { new object() }; _frameLock = new[] { new Lock() };
_percentLock = new[] { new object() }; _percentLock = new[] { new Lock() };
_resetTimer = new Timer(750); _resetTimer = new Timer(750);

View file

@ -4,6 +4,7 @@ using Ryujinx.Horizon.Sdk.OsTypes;
using Ryujinx.Horizon.Sdk.Sf; using Ryujinx.Horizon.Sdk.Sf;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Horizon.Sdk.Friends.Detail.Ipc namespace Ryujinx.Horizon.Sdk.Friends.Detail.Ipc
{ {
@ -13,7 +14,7 @@ namespace Ryujinx.Horizon.Sdk.Friends.Detail.Ipc
private readonly Uid _userId; private readonly Uid _userId;
private readonly FriendsServicePermissionLevel _permissionLevel; private readonly FriendsServicePermissionLevel _permissionLevel;
private readonly object _lock = new(); private readonly Lock _lock = new();
private SystemEventType _notificationEvent; private SystemEventType _notificationEvent;

View file

@ -2,6 +2,7 @@ using Ryujinx.Common;
using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Horizon.Sdk.OsTypes.Impl namespace Ryujinx.Horizon.Sdk.OsTypes.Impl
{ {
@ -13,7 +14,7 @@ namespace Ryujinx.Horizon.Sdk.OsTypes.Impl
private readonly List<MultiWaitHolderBase> _multiWaits; private readonly List<MultiWaitHolderBase> _multiWaits;
private readonly object _lock = new(); private readonly Lock _lock = new();
private int _waitingThreadHandle; private int _waitingThreadHandle;

View file

@ -1,6 +1,7 @@
using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Horizon.Sdk.Sf.Cmif namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{ {
@ -209,14 +210,14 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
} }
private readonly EntryManager _entryManager; private readonly EntryManager _entryManager;
private readonly object _entryOwnerLock; private readonly Lock _entryOwnerLock;
private readonly HashSet<Domain> _domains; private readonly HashSet<Domain> _domains;
private readonly int _maxDomains; private readonly int _maxDomains;
public ServerDomainManager(int entryCount, int maxDomains) public ServerDomainManager(int entryCount, int maxDomains)
{ {
_entryManager = new EntryManager(entryCount); _entryManager = new EntryManager(entryCount);
_entryOwnerLock = new object(); _entryOwnerLock = new Lock();
_domains = new HashSet<Domain>(); _domains = new HashSet<Domain>();
_maxDomains = maxDomains; _maxDomains = maxDomains;
} }

View file

@ -4,6 +4,7 @@ using Ryujinx.Horizon.Sdk.Sm;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Threading;
namespace Ryujinx.Horizon.Sdk.Sf.Hipc namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{ {
@ -17,7 +18,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
private readonly ulong _pointerBuffersBaseAddress; private readonly ulong _pointerBuffersBaseAddress;
private readonly ulong _savedMessagesBaseAddress; private readonly ulong _savedMessagesBaseAddress;
private readonly object _resourceLock; private readonly Lock _resourceLock;
private readonly ulong[] _sessionAllocationBitmap; private readonly ulong[] _sessionAllocationBitmap;
private readonly HashSet<ServerSession> _sessions; private readonly HashSet<ServerSession> _sessions;
private readonly HashSet<Server> _servers; private readonly HashSet<Server> _servers;
@ -42,7 +43,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
} }
} }
_resourceLock = new object(); _resourceLock = new Lock();
_sessionAllocationBitmap = new ulong[(maxSessions + 63) / 64]; _sessionAllocationBitmap = new ulong[(maxSessions + 63) / 64];
_sessions = new HashSet<ServerSession>(); _sessions = new HashSet<ServerSession>();
_servers = new HashSet<Server>(); _servers = new HashSet<Server>();

View file

@ -4,6 +4,7 @@ using Ryujinx.Horizon.Sdk.Sf.Cmif;
using Ryujinx.Horizon.Sdk.Sm; using Ryujinx.Horizon.Sdk.Sm;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading;
namespace Ryujinx.Horizon.Sdk.Sf.Hipc namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{ {
@ -16,8 +17,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
private readonly MultiWait _multiWait; private readonly MultiWait _multiWait;
private readonly MultiWait _waitList; private readonly MultiWait _waitList;
private readonly object _multiWaitSelectionLock; private readonly Lock _multiWaitSelectionLock;
private readonly object _waitListLock; private readonly Lock _waitListLock;
private readonly Event _requestStopEvent; private readonly Event _requestStopEvent;
private readonly Event _notifyEvent; private readonly Event _notifyEvent;
@ -39,8 +40,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
_multiWait = new MultiWait(); _multiWait = new MultiWait();
_waitList = new MultiWait(); _waitList = new MultiWait();
_multiWaitSelectionLock = new object(); _multiWaitSelectionLock = new Lock();
_waitListLock = new object(); _waitListLock = new Lock();
_requestStopEvent = new Event(EventClearMode.ManualClear); _requestStopEvent = new Event(EventClearMode.ManualClear);
_notifyEvent = new Event(EventClearMode.ManualClear); _notifyEvent = new Event(EventClearMode.ManualClear);

View file

@ -4,6 +4,7 @@ using Ryujinx.Common.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Threading;
using static SDL2.SDL; using static SDL2.SDL;
namespace Ryujinx.Input.SDL2 namespace Ryujinx.Input.SDL2
@ -55,7 +56,7 @@ namespace Ryujinx.Input.SDL2
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID, SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
}; };
private readonly object _userMappingLock = new(); private readonly Lock _userMappingLock = new();
private readonly List<ButtonMappingEntry> _buttonsUserMapping; private readonly List<ButtonMappingEntry> _buttonsUserMapping;

View file

@ -1,6 +1,7 @@
using Ryujinx.SDL2.Common; using Ryujinx.SDL2.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using static SDL2.SDL; using static SDL2.SDL;
namespace Ryujinx.Input.SDL2 namespace Ryujinx.Input.SDL2
@ -9,7 +10,7 @@ namespace Ryujinx.Input.SDL2
{ {
private readonly Dictionary<int, string> _gamepadsInstanceIdsMapping; private readonly Dictionary<int, string> _gamepadsInstanceIdsMapping;
private readonly List<string> _gamepadsIds; private readonly List<string> _gamepadsIds;
private readonly object _lock = new object(); private readonly Lock _lock = new();
public ReadOnlySpan<string> GamepadsIds public ReadOnlySpan<string> GamepadsIds
{ {

View file

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading;
using static SDL2.SDL; using static SDL2.SDL;
using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; using ConfigKey = Ryujinx.Common.Configuration.Hid.Key;
@ -24,7 +25,7 @@ namespace Ryujinx.Input.SDL2
} }
} }
private readonly object _userMappingLock = new(); private readonly Lock _userMappingLock = new();
#pragma warning disable IDE0052 // Remove unread private member #pragma warning disable IDE0052 // Remove unread private member
private readonly SDL2KeyboardDriver _driver; private readonly SDL2KeyboardDriver _driver;

View file

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading;
using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client; using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client;
using ControllerType = Ryujinx.Common.Configuration.Hid.ControllerType; using ControllerType = Ryujinx.Common.Configuration.Hid.ControllerType;
using PlayerIndex = Ryujinx.HLE.HOS.Services.Hid.PlayerIndex; using PlayerIndex = Ryujinx.HLE.HOS.Services.Hid.PlayerIndex;
@ -18,7 +19,7 @@ namespace Ryujinx.Input.HLE
{ {
private readonly CemuHookClient _cemuHookClient; private readonly CemuHookClient _cemuHookClient;
private readonly object _lock = new(); private readonly Lock _lock = new();
private bool _blockInputUpdates; private bool _blockInputUpdates;

View file

@ -1,6 +1,7 @@
using Ryujinx.Common.Pools; using Ryujinx.Common.Pools;
using Ryujinx.Memory.Range; using Ryujinx.Memory.Range;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Memory.Tracking namespace Ryujinx.Memory.Tracking
{ {
@ -26,7 +27,7 @@ namespace Ryujinx.Memory.Tracking
/// This lock must be obtained when traversing or updating the region-handle hierarchy. /// This lock must be obtained when traversing or updating the region-handle hierarchy.
/// It is not required when reading dirty flags. /// It is not required when reading dirty flags.
/// </summary> /// </summary>
internal object TrackingLock = new(); internal Lock TrackingLock = new();
/// <summary> /// <summary>
/// Create a new tracking structure for the given "physical" memory block, /// Create a new tracking structure for the given "physical" memory block,

View file

@ -51,7 +51,7 @@ namespace Ryujinx.Memory.Tracking
private event Action OnDirty; private event Action OnDirty;
private readonly object _preActionLock = new(); private readonly Lock _preActionLock = new();
private RegionSignal _preAction; // Action to perform before a read or write. This will block the memory access. private RegionSignal _preAction; // Action to perform before a read or write. This will block the memory access.
private PreciseRegionSignal _preciseAction; // Action to perform on a precise read or write. private PreciseRegionSignal _preciseAction; // Action to perform on a precise read or write.
private readonly List<VirtualRegion> _regions; private readonly List<VirtualRegion> _regions;
@ -278,7 +278,7 @@ namespace Ryujinx.Memory.Tracking
} }
// Temporarily release the tracking lock while we're running the action. // Temporarily release the tracking lock while we're running the action.
Monitor.Exit(_tracking.TrackingLock); _tracking.TrackingLock.Exit();
try try
{ {
@ -293,7 +293,7 @@ namespace Ryujinx.Memory.Tracking
} }
finally finally
{ {
Monitor.Enter(_tracking.TrackingLock); _tracking.TrackingLock.Enter();
} }
} }

View file

@ -36,7 +36,7 @@ namespace Ryujinx.SDL2.Common
private ConcurrentDictionary<uint, Action<SDL_Event>> _registeredWindowHandlers; private ConcurrentDictionary<uint, Action<SDL_Event>> _registeredWindowHandlers;
private readonly object _lock = new(); private readonly Lock _lock = new();
private SDL2Driver() { } private SDL2Driver() { }

View file

@ -117,7 +117,7 @@ namespace Ryujinx.Ava
private bool _dialogShown; private bool _dialogShown;
private readonly bool _isFirmwareTitle; private readonly bool _isFirmwareTitle;
private readonly object _lockObject = new(); private readonly Lock _lock = new();
public event EventHandler AppExit; public event EventHandler AppExit;
public event EventHandler<StatusInitEventArgs> StatusInitEvent; public event EventHandler<StatusInitEventArgs> StatusInitEvent;
@ -339,7 +339,7 @@ namespace Ryujinx.Ava
{ {
Task.Run(() => Task.Run(() =>
{ {
lock (_lockObject) lock (_lock)
{ {
string applicationName = Device.Processes.ActiveApplication.Name; string applicationName = Device.Processes.ActiveApplication.Name;
string sanitizedApplicationName = FileSystemUtils.SanitizeFileName(applicationName); string sanitizedApplicationName = FileSystemUtils.SanitizeFileName(applicationName);

View file

@ -4,6 +4,7 @@ using Ryujinx.Input;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Threading;
using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; using ConfigKey = Ryujinx.Common.Configuration.Hid.Key;
using Key = Ryujinx.Input.Key; using Key = Ryujinx.Input.Key;
@ -15,7 +16,7 @@ namespace Ryujinx.Ava.Input
private readonly AvaloniaKeyboardDriver _driver; private readonly AvaloniaKeyboardDriver _driver;
private StandardKeyboardInputConfig _configuration; private StandardKeyboardInputConfig _configuration;
private readonly object _userMappingLock = new(); private readonly Lock _userMappingLock = new();
public string Id { get; } public string Id { get; }
public string Name { get; } public string Name { get; }