Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ConcurrentSet.cs
Go to the documentation of this file.
1
using
System.Threading
;
2
3
namespace
System.Diagnostics.Tracing
;
4
5
internal
struct
ConcurrentSet
<KeyType, ItemType> where ItemType :
ConcurrentSetItem
<KeyType, ItemType>
6
{
7
private
ItemType[]
items
;
8
9
public
ItemType
TryGet
(KeyType
key
)
10
{
11
ItemType[]
array
=
items
;
12
if
(
array
==
null
)
13
{
14
goto
IL_0045;
15
}
16
int
num = 0;
17
int
num2 =
array
.Length;
18
ItemType val;
19
while
(
true
)
20
{
21
int
num3 = (num + num2) / 2;
22
val =
array
[num3];
23
int
num4 = val.Compare(
key
);
24
if
(num4 == 0)
25
{
26
break
;
27
}
28
if
(num4 < 0)
29
{
30
num = num3 + 1;
31
}
32
else
33
{
34
num2 = num3;
35
}
36
if
(num != num2)
37
{
38
continue
;
39
}
40
goto
IL_0045;
41
}
42
goto
IL_004d;
43
IL_004d:
44
return
val;
45
IL_0045:
46
val =
null
;
47
goto
IL_004d;
48
}
49
50
public
ItemType
GetOrAdd
(ItemType newItem)
51
{
52
ItemType[]
array
=
items
;
53
ItemType val;
54
while
(
true
)
55
{
56
ItemType[] array2;
57
if
(
array
==
null
)
58
{
59
array2 =
new
ItemType[1] { newItem };
60
goto
IL_0088;
61
}
62
int
num = 0;
63
int
num2 =
array
.Length;
64
while
(
true
)
65
{
66
int
num3 = (num + num2) / 2;
67
val =
array
[num3];
68
int
num4 = val.Compare(newItem);
69
if
(num4 == 0)
70
{
71
break
;
72
}
73
if
(num4 < 0)
74
{
75
num = num3 + 1;
76
}
77
else
78
{
79
num2 = num3;
80
}
81
if
(num != num2)
82
{
83
continue
;
84
}
85
goto
IL_005a;
86
}
87
break
;
88
IL_0088:
89
array2 =
Interlocked
.
CompareExchange
(ref
items
, array2,
array
);
90
if
(
array
!= array2)
91
{
92
array
= array2;
93
continue
;
94
}
95
val = newItem;
96
break
;
97
IL_005a:
98
int
num5 =
array
.Length;
99
array2 =
new
ItemType[num5 + 1];
100
Array
.
Copy
(
array
, array2, num);
101
array2[num] = newItem;
102
Array
.
Copy
(
array
, num, array2, num + 1, num5 - num);
103
goto
IL_0088;
104
}
105
return
val;
106
}
107
}
System.Array.Copy
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition
Array.cs:624
System.Array
Definition
Array.cs:16
System.Diagnostics.Tracing.ConcurrentSetItem
Definition
ConcurrentSetItem.cs:4
System.Threading.Interlocked.CompareExchange
static int CompareExchange(ref int location1, int value, int comparand)
System.Threading.Interlocked
Definition
Interlocked.cs:9
System.Diagnostics.Tracing
Definition
ActivityTracker.cs:4
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.key
@ key
System.ExceptionArgument.array
@ array
System.Diagnostics.Tracing.ConcurrentSet.TryGet
ItemType TryGet(KeyType key)
Definition
ConcurrentSet.cs:9
System.Diagnostics.Tracing.ConcurrentSet.GetOrAdd
ItemType GetOrAdd(ItemType newItem)
Definition
ConcurrentSet.cs:50
System.Diagnostics.Tracing.ConcurrentSet.items
ItemType[] items
Definition
ConcurrentSet.cs:7
System.Diagnostics.Tracing.ConcurrentSet
Definition
ConcurrentSet.cs:6
source
System.Private.CoreLib
System.Diagnostics.Tracing
ConcurrentSet.cs
Generated by
1.10.0