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

◆ AtomicLoopStateUpdate() [2/2]

bool System.Threading.Tasks.ParallelLoopStateFlags.AtomicLoopStateUpdate ( int newState,
int illegalStates,
ref int oldState )
inlinepackageinherited

Definition at line 15 of file ParallelLoopStateFlags.cs.

16 {
17 SpinWait spinWait = default(SpinWait);
18 while (true)
19 {
20 oldState = _loopStateFlags;
21 if ((oldState & illegalStates) != 0)
22 {
23 return false;
24 }
25 if (Interlocked.CompareExchange(ref _loopStateFlags, oldState | newState, oldState) == oldState)
26 {
27 break;
28 }
29 spinWait.SpinOnce();
30 }
31 return true;
32 }

References System.Threading.Tasks.ParallelLoopStateFlags._loopStateFlags, System.Threading.Interlocked.CompareExchange(), and System.Threading.SpinWait.SpinOnce().