Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SynchronizedList.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
3
namespace
System.Diagnostics
;
4
5
internal
sealed
class
SynchronizedList
<T>
6
{
7
private
readonly
List<T>
_list
;
8
9
private
uint
_version
;
10
11
public
int
Count
=>
_list
.Count;
12
13
public
SynchronizedList
()
14
{
15
_list
=
new
List<T>
();
16
}
17
18
public
void
Add
(T
item
)
19
{
20
lock
(
_list
)
21
{
22
_list
.Add(
item
);
23
_version
++;
24
}
25
}
26
27
public
bool
AddIfNotExist
(T
item
)
28
{
29
lock
(
_list
)
30
{
31
if
(!
_list
.Contains(
item
))
32
{
33
_list
.Add(
item
);
34
_version
++;
35
return
true
;
36
}
37
return
false
;
38
}
39
}
40
41
public
bool
Remove
(T
item
)
42
{
43
lock
(
_list
)
44
{
45
if
(
_list
.Remove(
item
))
46
{
47
_version
++;
48
return
true
;
49
}
50
return
false
;
51
}
52
}
53
54
public
void
EnumWithFunc<TParent>
(
ActivitySource
.Function<T,
TParent
> func,
ref
ActivityCreationOptions<TParent>
data,
ref
ActivitySamplingResult
samplingResult
,
ref
ActivityCreationOptions<ActivityContext>
dataWithContext
)
55
{
56
uint version =
_version
;
57
int
num = 0;
58
while
(num <
_list
.Count)
59
{
60
T
item
;
61
lock
(
_list
)
62
{
63
if
(version !=
_version
)
64
{
65
version =
_version
;
66
num = 0;
67
continue
;
68
}
69
item
=
_list
[num];
70
num++;
71
}
72
func(
item
,
ref
data,
ref
samplingResult
,
ref
dataWithContext
);
73
}
74
}
75
76
public
void
EnumWithAction
(
Action<T, object>
action
,
object
arg
)
77
{
78
uint version =
_version
;
79
int
num = 0;
80
while
(num <
_list
.Count)
81
{
82
T
arg2
;
83
lock
(
_list
)
84
{
85
if
(version !=
_version
)
86
{
87
version =
_version
;
88
num = 0;
89
continue
;
90
}
91
arg2
=
_list
[num];
92
num++;
93
}
94
action
(
arg2
,
arg
);
95
}
96
}
97
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Diagnostics.ActivitySource
Definition
ActivitySource.cs:8
System.Diagnostics.SynchronizedList.EnumWithAction
void EnumWithAction(Action< T, object > action, object arg)
Definition
SynchronizedList.cs:76
System.Diagnostics.SynchronizedList.EnumWithFunc< TParent >
void EnumWithFunc< TParent >(ActivitySource.Function< T, TParent > func, ref ActivityCreationOptions< TParent > data, ref ActivitySamplingResult samplingResult, ref ActivityCreationOptions< ActivityContext > dataWithContext)
Definition
SynchronizedList.cs:54
System.Diagnostics.SynchronizedList.Remove
bool Remove(T item)
Definition
SynchronizedList.cs:41
System.Diagnostics.SynchronizedList.Count
int Count
Definition
SynchronizedList.cs:11
System.Diagnostics.SynchronizedList._list
readonly List< T > _list
Definition
SynchronizedList.cs:7
System.Diagnostics.SynchronizedList.Add
void Add(T item)
Definition
SynchronizedList.cs:18
System.Diagnostics.SynchronizedList.AddIfNotExist
bool AddIfNotExist(T item)
Definition
SynchronizedList.cs:27
System.Diagnostics.SynchronizedList._version
uint _version
Definition
SynchronizedList.cs:9
System.Diagnostics.SynchronizedList.SynchronizedList
SynchronizedList()
Definition
SynchronizedList.cs:13
System.Diagnostics.SynchronizedList
Definition
SynchronizedList.cs:6
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Diagnostics.ActivitySamplingResult
ActivitySamplingResult
Definition
ActivitySamplingResult.cs:4
System.Diagnostics
Definition
AggregationManager.cs:6
System.ExceptionArgument.action
@ action
System.ExceptionArgument.item
@ item
source
System.Diagnostics.DiagnosticSource
System.Diagnostics
SynchronizedList.cs
Generated by
1.10.0