diff options
Diffstat (limited to 'src/Ryujinx.Common/Memory/PartialUnmaps')
3 files changed, 18 insertions, 16 deletions
diff --git a/src/Ryujinx.Common/Memory/PartialUnmaps/NativeReaderWriterLock.cs b/src/Ryujinx.Common/Memory/PartialUnmaps/NativeReaderWriterLock.cs index 78eeb16f..03d48fd8 100644 --- a/src/Ryujinx.Common/Memory/PartialUnmaps/NativeReaderWriterLock.cs +++ b/src/Ryujinx.Common/Memory/PartialUnmaps/NativeReaderWriterLock.cs @@ -1,6 +1,5 @@ using System.Runtime.InteropServices; using System.Threading; - using static Ryujinx.Common.Memory.PartialUnmaps.PartialUnmapHelpers; namespace Ryujinx.Common.Memory.PartialUnmaps @@ -14,15 +13,15 @@ namespace Ryujinx.Common.Memory.PartialUnmaps public int WriteLock; public int ReaderCount; - public static int WriteLockOffset; - public static int ReaderCountOffset; + public static readonly int WriteLockOffset; + public static readonly int ReaderCountOffset; /// <summary> /// Populates the field offsets for use when emitting native code. /// </summary> static NativeReaderWriterLock() { - NativeReaderWriterLock instance = new NativeReaderWriterLock(); + NativeReaderWriterLock instance = new(); WriteLockOffset = OffsetOf(ref instance, ref instance.WriteLock); ReaderCountOffset = OffsetOf(ref instance, ref instance.ReaderCount); @@ -35,7 +34,9 @@ namespace Ryujinx.Common.Memory.PartialUnmaps { // Must take write lock for a very short time to become a reader. - while (Interlocked.CompareExchange(ref WriteLock, 1, 0) != 0) { } + while (Interlocked.CompareExchange(ref WriteLock, 1, 0) != 0) + { + } Interlocked.Increment(ref ReaderCount); @@ -60,11 +61,15 @@ namespace Ryujinx.Common.Memory.PartialUnmaps Interlocked.Decrement(ref ReaderCount); - while (Interlocked.CompareExchange(ref WriteLock, 1, 0) != 0) { } + while (Interlocked.CompareExchange(ref WriteLock, 1, 0) != 0) + { + } // Wait for reader count to drop to 0, then take the lock again as the only reader. - while (Interlocked.CompareExchange(ref ReaderCount, 1, 0) != 0) { } + while (Interlocked.CompareExchange(ref ReaderCount, 1, 0) != 0) + { + } } /// <summary> diff --git a/src/Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapState.cs b/src/Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapState.cs index 5b0bc07e..a583930b 100644 --- a/src/Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapState.cs +++ b/src/Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapState.cs @@ -1,10 +1,8 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.InteropServices.Marshalling; using System.Runtime.Versioning; using System.Threading; - using static Ryujinx.Common.Memory.PartialUnmaps.PartialUnmapHelpers; namespace Ryujinx.Common.Memory.PartialUnmaps @@ -35,7 +33,7 @@ namespace Ryujinx.Common.Memory.PartialUnmaps [SupportedOSPlatform("windows")] [LibraryImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs (UnmanagedType.Bool)] + [return: MarshalAs(UnmanagedType.Bool)] private static partial bool CloseHandle(IntPtr hObject); [SupportedOSPlatform("windows")] @@ -48,7 +46,7 @@ namespace Ryujinx.Common.Memory.PartialUnmaps /// </summary> static unsafe PartialUnmapState() { - PartialUnmapState instance = new PartialUnmapState(); + PartialUnmapState instance = new(); PartialUnmapLockOffset = OffsetOf(ref instance, ref instance.PartialUnmapLock); PartialUnmapsCountOffset = OffsetOf(ref instance, ref instance.PartialUnmapsCount); @@ -160,4 +158,4 @@ namespace Ryujinx.Common.Memory.PartialUnmaps } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.Common/Memory/PartialUnmaps/ThreadLocalMap.cs b/src/Ryujinx.Common/Memory/PartialUnmaps/ThreadLocalMap.cs index a3bd5be8..a3c3dc57 100644 --- a/src/Ryujinx.Common/Memory/PartialUnmaps/ThreadLocalMap.cs +++ b/src/Ryujinx.Common/Memory/PartialUnmaps/ThreadLocalMap.cs @@ -1,6 +1,5 @@ using System.Runtime.InteropServices; using System.Threading; - using static Ryujinx.Common.Memory.PartialUnmaps.PartialUnmapHelpers; namespace Ryujinx.Common.Memory.PartialUnmaps @@ -18,15 +17,15 @@ namespace Ryujinx.Common.Memory.PartialUnmaps public Array20<int> ThreadIds; public Array20<T> Structs; - public static int ThreadIdsOffset; - public static int StructsOffset; + public static readonly int ThreadIdsOffset; + public static readonly int StructsOffset; /// <summary> /// Populates the field offsets for use when emitting native code. /// </summary> static ThreadLocalMap() { - ThreadLocalMap<T> instance = new ThreadLocalMap<T>(); + ThreadLocalMap<T> instance = new(); ThreadIdsOffset = OffsetOf(ref instance, ref instance.ThreadIds); StructsOffset = OffsetOf(ref instance, ref instance.Structs); |
