diff options
Diffstat (limited to 'src/mscorlib/src/System/Threading/SpinWait.cs')
-rw-r--r-- | src/mscorlib/src/System/Threading/SpinWait.cs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mscorlib/src/System/Threading/SpinWait.cs b/src/mscorlib/src/System/Threading/SpinWait.cs index c2cd0b6203..1b31407e0f 100644 --- a/src/mscorlib/src/System/Threading/SpinWait.cs +++ b/src/mscorlib/src/System/Threading/SpinWait.cs @@ -14,6 +14,7 @@ using System; using System.Runtime.ConstrainedExecution; using System.Security.Permissions; using System.Threading; +using System.Diagnostics; using System.Diagnostics.Contracts; using System.Diagnostics.CodeAnalysis; @@ -69,7 +70,6 @@ namespace System.Threading /// threads must spin, each should use its own instance of SpinWait. /// </para> /// </remarks> - [HostProtection(Synchronization = true, ExternalThreading = true)] public struct SpinWait { @@ -132,10 +132,6 @@ namespace System.Threading // remove the thread from the scheduler's queue for 10+ms, if the system is // configured to use the (default) coarse-grained system timer. // - -#if !FEATURE_CORECLR - CdsSyncEtwBCLProvider.Log.SpinWait_NextSpinWillYield(); -#endif int yieldsSoFar = (m_count >= YIELD_THRESHOLD ? m_count - YIELD_THRESHOLD : m_count); if ((yieldsSoFar % SLEEP_1_EVERY_HOW_MANY_TIMES) == (SLEEP_1_EVERY_HOW_MANY_TIMES - 1)) @@ -197,7 +193,7 @@ namespace System.Threading #endif SpinUntil(condition, Timeout.Infinite); #if DEBUG - Contract.Assert(result); + Debug.Assert(result); #endif } @@ -220,7 +216,7 @@ namespace System.Threading if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) { throw new System.ArgumentOutOfRangeException( - "timeout", timeout, Environment.GetResourceString("SpinWait_SpinUntil_TimeoutWrong")); + nameof(timeout), timeout, Environment.GetResourceString("SpinWait_SpinUntil_TimeoutWrong")); } // Call wait with the timeout milliseconds @@ -242,11 +238,11 @@ namespace System.Threading if (millisecondsTimeout < Timeout.Infinite) { throw new ArgumentOutOfRangeException( - "millisecondsTimeout", millisecondsTimeout, Environment.GetResourceString("SpinWait_SpinUntil_TimeoutWrong")); + nameof(millisecondsTimeout), millisecondsTimeout, Environment.GetResourceString("SpinWait_SpinUntil_TimeoutWrong")); } if (condition == null) { - throw new ArgumentNullException("condition", Environment.GetResourceString("SpinWait_SpinUntil_ArgumentNull")); + throw new ArgumentNullException(nameof(condition), Environment.GetResourceString("SpinWait_SpinUntil_ArgumentNull")); } uint startTime = 0; if (millisecondsTimeout != 0 && millisecondsTimeout != Timeout.Infinite) @@ -304,7 +300,7 @@ namespace System.Threading s_lastProcessorCountRefreshTicks = now; } - Contract.Assert(procCount > 0 && procCount <= 64, + Debug.Assert(procCount > 0 && procCount <= 64, "Processor count not within the expected range (1 - 64)."); return procCount; @@ -345,7 +341,7 @@ namespace System.Threading public static int UpdateTimeOut(uint startTime, int originalWaitMillisecondsTimeout) { // The function must be called in case the time out is not infinite - Contract.Assert(originalWaitMillisecondsTimeout != Timeout.Infinite); + Debug.Assert(originalWaitMillisecondsTimeout != Timeout.Infinite); uint elapsedMilliseconds = (GetTime() - startTime); |