Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AggregatorStore.cs
Go to the documentation of this file.
4
6
7internal struct AggregatorStore<TAggregator> where TAggregator : Aggregator
8{
9 private volatile object _stateUnion;
10
12
14
21
31
38
84
85 public TAggregator GetAggregator()
86 {
88 while (true)
89 {
90 object stateUnion = _stateUnion;
91 if (stateUnion == null)
92 {
93 TAggregator val = _createAggregatorFunc();
94 if (val == null)
95 {
96 return val;
97 }
98 if (Interlocked.CompareExchange(ref _stateUnion, val, null) == null)
99 {
100 return val;
101 }
102 continue;
103 }
104 if (stateUnion is TAggregator result)
105 {
106 return result;
107 }
109 {
110 return multiSizeLabelNameDictionary.GetNoLabelAggregator(_createAggregatorFunc);
111 }
114 {
115 break;
116 }
117 }
118 return multiSizeLabelNameDictionary2.GetNoLabelAggregator(_createAggregatorFunc);
119 }
120
122 {
124 while (true)
125 {
126 object stateUnion = _stateUnion;
127 if (stateUnion == null)
128 {
131 {
132 return fixedSizeLabelNameDictionary.GetValuesDictionary(in names);
133 }
134 continue;
135 }
137 {
138 return fixedSizeLabelNameDictionary2.GetValuesDictionary(in names);
139 }
141 {
142 return multiSizeLabelNameDictionary.GetFixedSizeLabelNameDictionary<TStringSequence, TObjectSequence>().GetValuesDictionary(in names);
143 }
146 {
147 break;
148 }
149 }
150 return multiSizeLabelNameDictionary2.GetFixedSizeLabelNameDictionary<TStringSequence, TObjectSequence>().GetValuesDictionary(in names);
151 }
152}
static int CompareExchange(ref int location1, int value, int comparand)
ConcurrentDictionary< TObjectSequence, TAggregator > GetLabelValuesDictionary< TStringSequence, TObjectSequence >(in TStringSequence names)
volatile AggregatorLookupFunc< TAggregator > _cachedLookupFunc
TAggregator GetAggregatorSlow(ReadOnlySpan< KeyValuePair< string, object > > labels)
void Collect(Action< LabeledAggregationStatistics > visitFunc)
AggregatorStore(Func< TAggregator > createAggregator)
TAggregator GetAggregator(ReadOnlySpan< KeyValuePair< string, object > > labels)
readonly Func< TAggregator > _createAggregatorFunc