0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 19:15:47 +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; 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; private readonly object _lock;
public Block(MemoryTracking tracking, Func<ulong, ulong> readPtCallback, MemoryBlock memory, ulong size, object locker) : base(memory, size) 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 MemoryTracking _tracking;
private readonly Func<ulong, ulong> _readPtCallback; 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; private readonly object _lock;
public AddressSpacePartitionAllocator( public AddressSpacePartitionAllocator(

View file

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

View file

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