Blocks should be synchronized on read-only fields (#5212)

* Blocks should be synchronized on read-only fields

* more readonlys

* fix alignment

* more

* Update ISelfController.cs

* simplify new

* simplify new
This commit is contained in:
Marco Carvalho 2023-06-14 21:34:55 -03:00 committed by GitHub
parent f978d3726a
commit 82f90704a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 60 additions and 68 deletions

View file

@ -60,7 +60,7 @@ namespace Ryujinx.HLE.HOS.Applets
private bool _canAcceptController = false;
private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard;
private object _lock = new object();
private readonly object _lock = new();
public event EventHandler AppletStateChanged;

View file

@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
private const int TextBoxBlinkSleepMilliseconds = 100;
private const int RendererWaitTimeoutMilliseconds = 100;
private readonly object _stateLock = new object();
private readonly object _stateLock = new();
private SoftwareKeyboardUiState _state = new SoftwareKeyboardUiState();
private SoftwareKeyboardRendererBase _renderer;

View file

@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
const string CancelText = "Cancel";
const string ControllerToggleText = "Toggle input";
private readonly object _bufferLock = new object();
private readonly object _bufferLock = new();
private RenderingSurfaceInfo _surfaceInfo = null;
private Image<Argb32> _surface = null;
@ -311,7 +311,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
private static RectangleF MeasureString(ReadOnlySpan<char> text, Font font)
{
RendererOptions options = new RendererOptions(font);
if (text == "")
{
FontRectangle emptyRectangle = TextMeasurer.Measure(" ", options);

View file

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

View file

@ -40,8 +40,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public ProcessState State { get; private set; }
private object _processLock;
private object _threadingLock;
private readonly object _processLock = new();
private readonly object _threadingLock = new();
public KAddressArbiter AddressArbiter { get; private set; }
@ -94,9 +94,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public KProcess(KernelContext context, bool allowCodeMemoryForJit = false) : base(context)
{
_processLock = new object();
_threadingLock = new object();
AddressArbiter = new KAddressArbiter(context);
_fullTlsPages = new SortedDictionary<ulong, KTlsPageInfo>();

View file

@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public bool WaitingInArbitration { get; set; }
private object _activityOperationLock;
private readonly object _activityOperationLock = new();
public KThread(KernelContext context) : base(context)
{
@ -123,8 +123,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
_mutexWaiters = new LinkedList<KThread>();
_pinnedWaiters = new LinkedList<KThread>();
_activityOperationLock = new object();
}
public Result Initialize(

View file

@ -17,8 +17,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
private KEvent _accumulatedSuspendedTickChangedEvent;
private int _accumulatedSuspendedTickChangedEventHandle;
private object _fatalSectionLock = new object();
private int _fatalSectionCount;
private readonly object _fatalSectionLock = new();
private int _fatalSectionCount;
// TODO: Set this when the game goes in suspension (go back to home menu ect), we currently don't support that so we can keep it set to 0.
private ulong _accumulatedSuspendedTickValue = 0;
@ -429,4 +429,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
}
}
}

View file

@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
private readonly UserId _userId;
private readonly FriendServicePermissionLevel _permissionLevel;
private readonly object _lock = new object();
private readonly object _lock = new();
private KEvent _notificationEvent;
private int _notificationEventHandle = 0;

View file

@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
private NvFence _previousFailingFence;
private uint _failingCount;
public readonly object Lock = new object();
public readonly object Lock = new();
/// <summary>
/// Max failing count until waiting on CPU.

View file

@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
private Switch _device;
private object _syncpointAllocatorLock = new object();
private readonly object _syncpointAllocatorLock = new();
public NvHostSyncpt(Switch device)
{

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
private static ConcurrentDictionary<ulong, BsdContext> _registry = new ConcurrentDictionary<ulong, BsdContext>();
private readonly object _lock = new object();
private readonly object _lock = new();
private List<IFileDescriptor> _fds;

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
private ulong _value;
private readonly EventFdFlags _flags;
private object _lock = new object();
private readonly object _lock = new();
public bool Blocking { get => !_flags.HasFlag(EventFdFlags.NonBlocking); set => throw new NotSupportedException(); }

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Spl
{
private RandomNumberGenerator _rng;
private object _lock = new object();
private readonly object _lock = new();
public IRandomInterface(ServiceCtx context)
{

View file

@ -40,13 +40,13 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
}
}
private VirtualFileSystem _virtualFileSystem;
private VirtualFileSystem _virtualFileSystem;
private IntegrityCheckLevel _fsIntegrityCheckLevel;
private ContentManager _contentManager;
private bool _initialized;
private ContentManager _contentManager;
private bool _initialized;
private Dictionary<CaCertificateId, CertStoreEntry> _certificates;
private object _lock = new object();
private readonly object _lock = new();
private struct CertStoreFileHeader
{

View file

@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
public bool EnableExternalEvent;
public int MaxBufferCountCached;
public readonly object Lock = new object();
public readonly object Lock = new();
private KEvent _waitBufferFreeEvent;
private KEvent _frameAvailableEvent;

View file

@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
private uint _currentCallbackTicket;
private uint _callbackTicket;
private readonly object _callbackLock = new object();
private readonly object _callbackLock = new();
public BufferQueueProducer(BufferQueueCore core, ITickSource tickSource)
{

View file

@ -23,7 +23,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
protected BufferQueueConsumer Consumer;
protected readonly object Lock = new object();
protected readonly object Lock = new();
private IConsumerListener _listener;
@ -168,7 +168,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
Slot slot = Slots[slotIndex];
// TODO: Check this. On Android, this checks the "handle". I assume NvMapHandle is the handle, but it might not be.
// TODO: Check this. On Android, this checks the "handle". I assume NvMapHandle is the handle, but it might not be.
return !slot.GraphicBuffer.IsNull && slot.GraphicBuffer.Object.Buffer.Surfaces[0].NvMapHandle == graphicBuffer.Object.Buffer.Surfaces[0].NvMapHandle;
}
}

View file

@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
private int _swapInterval;
private int _swapIntervalDelay;
private readonly object Lock = new object();
private readonly object Lock = new();
public long RenderLayerId { get; private set; }

View file

@ -13,14 +13,13 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
private UInt128 _timeZoneRuleVersion;
private uint _totalLocationNameCount;
private SteadyClockTimePoint _timeZoneUpdateTimePoint;
private object _lock;
private readonly object _lock = new();
public TimeZoneManager()
{
_isInitialized = false;
_deviceLocationName = "UTC";
_timeZoneRuleVersion = new UInt128();
_lock = new object();
_myRules = new Box<TimeZoneRule>();
_timeZoneUpdateTimePoint = SteadyClockTimePoint.GetRandom();