Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ParallelLoopStateFlags.cs
Go to the documentation of this file.
1
namespace
System.Threading.Tasks
;
2
3
internal
class
ParallelLoopStateFlags
4
{
5
private
volatile
int
_loopStateFlags
;
6
7
internal
int
LoopStateFlags
=>
_loopStateFlags
;
8
9
internal
bool
AtomicLoopStateUpdate
(
int
newState,
int
illegalStates)
10
{
11
int
oldState = 0;
12
return
AtomicLoopStateUpdate
(newState, illegalStates, ref oldState);
13
}
14
15
internal
bool
AtomicLoopStateUpdate
(
int
newState,
int
illegalStates, ref
int
oldState)
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
}
33
34
internal
void
SetExceptional
()
35
{
36
AtomicLoopStateUpdate
(1, 0);
37
}
38
39
internal
void
Stop
()
40
{
41
if
(!
AtomicLoopStateUpdate
(4, 2))
42
{
43
throw
new
InvalidOperationException
(
System
.
SR
.
ParallelState_Stop_InvalidOperationException_StopAfterBreak
);
44
}
45
}
46
47
internal
bool
Cancel
()
48
{
49
return
AtomicLoopStateUpdate
(8, 0);
50
}
51
}
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.SR.ParallelState_Stop_InvalidOperationException_StopAfterBreak
static string ParallelState_Stop_InvalidOperationException_StopAfterBreak
Definition
SR.cs:26
System.SR
Definition
SR.cs:7
System.Threading.Interlocked.CompareExchange
static int CompareExchange(ref int location1, int value, int comparand)
System.Threading.Interlocked
Definition
Interlocked.cs:9
System.Threading.Tasks.ParallelLoopStateFlags._loopStateFlags
volatile int _loopStateFlags
Definition
ParallelLoopStateFlags.cs:5
System.Threading.Tasks.ParallelLoopStateFlags.SetExceptional
void SetExceptional()
Definition
ParallelLoopStateFlags.cs:34
System.Threading.Tasks.ParallelLoopStateFlags.Stop
void Stop()
Definition
ParallelLoopStateFlags.cs:39
System.Threading.Tasks.ParallelLoopStateFlags.Cancel
bool Cancel()
Definition
ParallelLoopStateFlags.cs:47
System.Threading.Tasks.ParallelLoopStateFlags.AtomicLoopStateUpdate
bool AtomicLoopStateUpdate(int newState, int illegalStates)
Definition
ParallelLoopStateFlags.cs:9
System.Threading.Tasks.ParallelLoopStateFlags.LoopStateFlags
int LoopStateFlags
Definition
ParallelLoopStateFlags.cs:7
System.Threading.Tasks.ParallelLoopStateFlags.AtomicLoopStateUpdate
bool AtomicLoopStateUpdate(int newState, int illegalStates, ref int oldState)
Definition
ParallelLoopStateFlags.cs:15
System.Threading.Tasks.ParallelLoopStateFlags
Definition
ParallelLoopStateFlags.cs:4
System.Threading.Tasks
Definition
TaskToApm.cs:3
System
Definition
BlockingCollection.cs:8
System.Threading.SpinWait.SpinOnce
void SpinOnce()
Definition
SpinWait.cs:33
System.Threading.SpinWait
Definition
SpinWait.cs:4
source
System.Threading.Tasks.Parallel
System.Threading.Tasks
ParallelLoopStateFlags.cs
Generated by
1.10.0