Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ParallelLoopState.cs
Go to the documentation of this file.
2
4
5[DebuggerDisplay("ShouldExitCurrentIteration = {ShouldExitCurrentIteration}")]
6public class ParallelLoopState
7{
9
17
19
20 public bool IsStopped => (_flagsBase.LoopStateFlags & 4) != 0;
21
22 public bool IsExceptional => (_flagsBase.LoopStateFlags & 1) != 0;
23
31
33
35 {
36 _flagsBase = fbase;
37 }
38
39 public void Stop()
40 {
42 }
43
48
49 public void Break()
50 {
52 }
53
54 internal static void Break(int iteration, ParallelLoopStateFlags32 pflags)
55 {
56 int oldState = 0;
57 if (!pflags.AtomicLoopStateUpdate(2, 13, ref oldState))
58 {
59 if (((uint)oldState & 4u) != 0)
60 {
62 }
63 return;
64 }
65 int lowestBreakIteration = pflags._lowestBreakIteration;
66 if (iteration >= lowestBreakIteration)
67 {
68 return;
69 }
70 SpinWait spinWait = default(SpinWait);
71 while (Interlocked.CompareExchange(ref pflags._lowestBreakIteration, iteration, lowestBreakIteration) != lowestBreakIteration)
72 {
73 spinWait.SpinOnce();
74 lowestBreakIteration = pflags._lowestBreakIteration;
75 if (iteration > lowestBreakIteration)
76 {
77 break;
78 }
79 }
80 }
81
82 internal static void Break(long iteration, ParallelLoopStateFlags64 pflags)
83 {
84 int oldState = 0;
85 if (!pflags.AtomicLoopStateUpdate(2, 13, ref oldState))
86 {
87 if (((uint)oldState & 4u) != 0)
88 {
90 }
91 return;
92 }
93 long lowestBreakIteration = pflags.LowestBreakIteration;
94 if (iteration >= lowestBreakIteration)
95 {
96 return;
97 }
98 SpinWait spinWait = default(SpinWait);
99 while (Interlocked.CompareExchange(ref pflags._lowestBreakIteration, iteration, lowestBreakIteration) != lowestBreakIteration)
100 {
101 spinWait.SpinOnce();
102 lowestBreakIteration = pflags.LowestBreakIteration;
103 if (iteration > lowestBreakIteration)
104 {
105 break;
106 }
107 }
108 }
109}
static string ParallelState_Break_InvalidOperationException_BreakAfterStop
Definition SR.cs:24
static string ParallelState_NotSupportedException_UnsupportedMethod
Definition SR.cs:28
Definition SR.cs:7
static int CompareExchange(ref int location1, int value, int comparand)
bool AtomicLoopStateUpdate(int newState, int illegalStates)
static void Break(long iteration, ParallelLoopStateFlags64 pflags)
readonly ParallelLoopStateFlags _flagsBase
static void Break(int iteration, ParallelLoopStateFlags32 pflags)
ParallelLoopState(ParallelLoopStateFlags fbase)