0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 14:35:46 +00:00

misc: One additional usage of Lock & comment why it's not used on the others.

This commit is contained in:
Evan Husted 2024-12-21 17:05:46 -06:00
parent 5b36a9cf9f
commit 4171913baf
4 changed files with 14 additions and 7 deletions

View file

@ -115,6 +115,9 @@ namespace Ryujinx.Cpu.Jit.HostTracked
}
private readonly AddressIntrusiveRedBlackTree<Mapping> _mappingTree;
// type is not Lock due to the unique usage of this mechanism,
// an arbitrary object is used as the lock passed in by constructor.
private readonly object _lock;
public Block(MemoryTracking tracking, Func<ulong, ulong> readPtCallback, MemoryBlock memory, ulong size, object locker) : base(memory, size)
@ -174,6 +177,9 @@ namespace Ryujinx.Cpu.Jit.HostTracked
private readonly MemoryTracking _tracking;
private readonly Func<ulong, ulong> _readPtCallback;
// type is not Lock due to the unique usage of this mechanism,
// an arbitrary object is used as the lock passed in by constructor.
private readonly object _lock;
public AddressSpacePartitionAllocator(

View file

@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
private readonly long[] _current2;
private readonly long[] _peak;
private readonly object _lock = new();
private readonly Lock _lock = new();
private readonly LinkedList<KThread> _waitingThreads;

View file

@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
class KCriticalSection
{
private readonly KernelContext _context;
private readonly object _lock = new();
private int _recursionCount;
public object Lock => _lock;
// type is not Lock due to Monitor class usage
public object Lock { get; } = new();
public KCriticalSection(KernelContext context)
{
@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public void Enter()
{
Monitor.Enter(_lock);
Monitor.Enter(Lock);
_recursionCount++;
}
@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
ulong scheduledCoresMask = KScheduler.SelectThreads(_context);
Monitor.Exit(_lock);
Monitor.Exit(Lock);
KThread currentThread = KernelStatic.GetCurrentThread();
bool isCurrentThreadSchedulable = currentThread != null && currentThread.IsSchedulable;
@ -56,7 +56,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
else
{
Monitor.Exit(_lock);
Monitor.Exit(Lock);
}
}
}

View file

@ -10,6 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
private ulong _value;
private readonly EventFdFlags _flags;
// type is not Lock due to Monitor class usage
private readonly object _lock = new();
public bool Blocking { get => !_flags.HasFlag(EventFdFlags.NonBlocking); set => throw new NotSupportedException(); }