Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SpinWaitForCondition()

bool System.Threading.LowLevelSpinWaiter.SpinWaitForCondition ( Func< bool > condition,
int spinCount,
int sleep0Threshold )
inline

Definition at line 7 of file LowLevelSpinWaiter.cs.

8 {
9 int processorCount = Environment.ProcessorCount;
10 int num = Interlocked.Increment(ref _spinningThreadCount);
11 try
12 {
13 if (num <= processorCount)
14 {
15 for (int i = ((processorCount <= 1) ? sleep0Threshold : 0); i < spinCount; i++)
16 {
17 Wait(i, sleep0Threshold, processorCount);
18 if (condition())
19 {
20 return true;
21 }
22 }
23 }
24 }
25 finally
26 {
27 Interlocked.Decrement(ref _spinningThreadCount);
28 }
29 return false;
30 }
static void Wait(int spinIndex, int sleep0Threshold, int processorCount)

References System.Threading.LowLevelSpinWaiter._spinningThreadCount, System.Threading.Interlocked.Decrement(), System.Threading.Interlocked.Increment(), System.Environment.ProcessorCount, and System.Threading.LowLevelSpinWaiter.Wait().

Referenced by System.Threading.LowLevelLock.WaitAndAcquire().