Skip to content

Commit

Permalink
Small cleanup for Lock in Mono
Browse files Browse the repository at this point in the history
- Used the project property instead of disabling the compiler warning. Probably a bit cleaner, and would enable using Lock in other libraries to try it out.
- Undid an unnecessary change from dotnet#87672
  • Loading branch information
kouvel committed Nov 1, 2023
1 parent 7e316e2 commit 4b8bc9c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<Platforms>x64;x86;arm;armv6;arm64;riscv64;s390x;wasm;ppc64le</Platforms>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>

<!-- CA2252: Opt in to preview features before using them (Lock) -->
<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>

<!-- Note that various places in SPCL depend on this resource name i.e. TplEventSource -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ private static void ReliableEnterTimeout(object obj, int timeout, ref bool lockT
try_enter_with_atomic_var(obj, timeout, true, ref lockTaken);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
public static long LockContentionCount => Monitor_get_lock_contention_count() + Lock.ContentionCount;
#pragma warning restore CA2252

[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern long Monitor_get_lock_contention_count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace System.Threading
//
internal partial class TimerQueue
{
public static long TickCount64 => Environment.TickCount64;
private static long TickCount64 => Environment.TickCount64;
private static List<TimerQueue>? s_scheduledTimers;
private static List<TimerQueue>? s_scheduledTimersToFire;
private static long s_shortestDueTimeMs = long.MaxValue;
Expand Down

0 comments on commit 4b8bc9c

Please sign in to comment.