From 55ceb9339b46bf6956a3bc3a4a3fc45ad072cef9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 14 Nov 2024 10:57:14 -0700 Subject: [PATCH] [WASI] throw PNSE in `ManualResetEventSlim.Wait` Otherwise, we'll just busy-wait forever, since WASI is not (yet) mulithread-capable. Signed-off-by: Joel Dice --- .../src/System/Threading/ManualResetEventSlim.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs index a9b8c10c03318..5f6bba992ae32 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs @@ -484,6 +484,10 @@ public bool Wait(int millisecondsTimeout) #endif public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) { +#if TARGET_WASI + _ = s_cancellationTokenCallback; + throw new PlatformNotSupportedException("ManualResetEventSlim.Wait not supported on WASI"); +#else // not TARGET_WASI ObjectDisposedException.ThrowIf(IsDisposed, this); cancellationToken.ThrowIfCancellationRequested(); // an early convenience check @@ -595,6 +599,7 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) } // automatically disposes (and unregisters) the callback return true; // done. The wait was satisfied. +#endif // not TARGET_WASI } ///