diff --git a/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueueSegment.cs b/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueueSegment.cs index 85224a537a5..c724285c7ed 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueueSegment.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueueSegment.cs @@ -193,7 +193,7 @@ public bool TryDequeue(out T item) } // Lost a race. Spin a bit, then try again. - spinner.SpinOnce(); + spinner.SpinOnce(sleep1Threshold: -1); } } @@ -254,7 +254,7 @@ public bool TryPeek(out T result, bool resultUsed) } // Lost a race. Spin a bit, then try again. - spinner.SpinOnce(); + spinner.SpinOnce(sleep1Threshold: -1); } } @@ -311,7 +311,7 @@ public bool TryEnqueue(T item) } // Lost a race. Spin a bit, then try again. - spinner.SpinOnce(); + spinner.SpinOnce(sleep1Threshold: -1); } } diff --git a/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs b/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs index dab6bd9a4f0..dd3de830588 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs @@ -551,7 +551,7 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) var spinner = new SpinWait(); while (spinner.Count < spinCount) { - spinner.SpinOnce(SpinWait.Sleep1ThresholdForLongSpinBeforeWait); + spinner.SpinOnce(sleep1Threshold: -1); if (IsSet) { @@ -720,7 +720,7 @@ private void UpdateStateAtomically(int newBits, int updateBitsMask) return; } - sw.SpinOnce(); + sw.SpinOnce(sleep1Threshold: -1); } while (true); } diff --git a/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs b/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs index ad252535480..01e71d1f002 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs @@ -89,16 +89,6 @@ public struct SpinWait /// internal static readonly int SpinCountforSpinBeforeWait = PlatformHelper.IsSingleProcessor ? 1 : 35; - /// - /// Typically, Sleep(1) should not be issued for a spin-wait before a proper wait because it is usually more beneficial - /// to just issue the proper wait. For longer spin-waits (when the spin count is configurable), this value may be used as - /// a threshold for issuing Sleep(1). - /// - /// - /// Should be greater than so that Sleep(1) would not be used by default. - /// - internal const int Sleep1ThresholdForLongSpinBeforeWait = 40; - // The number of times we've spun already. private int _count;