Skip to content

Commit 812524f

Browse files
committed
fix non-browser+threads builds
1 parent 552f9a5 commit 812524f

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.AsyncWait.Browser.Threads.Mono.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ private LowLevelLifoSemaphore(int initialSignalCount, int maximumSignalCount, in
4040
#pragma warning disable IDE0060
4141
private void CreateAsyncWait(int maximumSignalCount)
4242
{
43-
_kind = LifoSemaphoreKind.AsyncWait;
44-
lifo_semaphore = InitInternal((int)_kind);
43+
Kind = LifoSemaphoreKind.AsyncWait;
44+
lifo_semaphore = InitInternal((int)Kind);
4545
}
4646
#pragma warning restore IDE0060
4747

src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,46 @@ namespace System.Threading
88
internal sealed unsafe partial class LowLevelLifoSemaphore : IDisposable
99
{
1010
private IntPtr lifo_semaphore;
11-
#if FEATURE_WASM_THREADS
11+
#if TARGET_BROWSER && FEATURE_WASM_THREADS
1212
private LifoSemaphoreKind _kind;
13+
#endif
14+
15+
#pragma warning disable CA1822
16+
private LifoSemaphoreKind Kind
17+
#pragma warning restore CA1822
18+
{
19+
get
20+
{
21+
#if TARGET_BROWSER && FEATURE_WASM_THREADS
22+
return _kind;
23+
#else
24+
return LifoSemaphoreKind.Normal;
25+
#endif
26+
}
27+
set
28+
{
29+
#if TARGET_BROWSER && FEATURE_WASM_THREADS
30+
_kind = value;
31+
#endif
32+
}
33+
}
1334

1435
// Keep in sync with lifo-semaphore.h
1536
private enum LifoSemaphoreKind : int {
1637
Normal = 1,
38+
#if TARGET_BROWSER && FEATURE_WASM_THREADS
1739
AsyncWait = 2,
18-
}
1940
#endif
41+
}
2042

2143
[MethodImplAttribute(MethodImplOptions.InternalCall)]
2244
private static extern IntPtr InitInternal(int kind);
2345

2446
#pragma warning disable IDE0060
2547
private void Create(int maximumSignalCount)
2648
{
27-
_kind = LifoSemaphoreKind.Normal;
28-
lifo_semaphore = InitInternal((int)_kind);
49+
Kind = LifoSemaphoreKind.Normal;
50+
lifo_semaphore = InitInternal((int)Kind);
2951
}
3052
#pragma warning restore IDE0060
3153

@@ -36,7 +58,7 @@ public void Dispose()
3658
{
3759
DeleteInternal(lifo_semaphore);
3860
lifo_semaphore = IntPtr.Zero;
39-
_kind = (LifoSemaphoreKind)0;
61+
Kind = (LifoSemaphoreKind)0;
4062
}
4163

4264
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -48,10 +70,14 @@ private bool WaitCore(int timeoutMs)
4870
return TimedWaitInternal(lifo_semaphore, timeoutMs) != 0;
4971
}
5072

73+
#pragma warning disable CA1822
5174
private void ThrowIfInvalidSemaphoreKind(LifoSemaphoreKind expected)
75+
#pragma warning restore CA1822
5276
{
77+
#if TARGET_BROWSER && FEATURE_WASM_THREADS
5378
if (_kind != expected)
5479
throw new InvalidOperationException ($"Unexpected LowLevelLifoSemaphore kind {_kind} expected {expected}");
80+
#endif
5581
}
5682

5783
[MethodImplAttribute(MethodImplOptions.InternalCall)]

0 commit comments

Comments
 (0)