Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Trim()

void System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.LockedStack.Trim ( int currentMilliseconds,
int id,
Utilities::MemoryPressure pressure,
int bucketSize )
inline

Definition at line 121 of file TlsOverPerCoreLockedStacksArrayPool.cs.

122 {
123 if (_count == 0)
124 {
125 return;
126 }
127 int num = ((pressure == Utilities.MemoryPressure.High) ? 10000 : 60000);
128 lock (this)
129 {
130 if (_count == 0)
131 {
132 return;
133 }
134 if (_millisecondsTimestamp == 0)
135 {
137 }
138 else
139 {
141 {
142 return;
143 }
144 ArrayPoolEventSource log = ArrayPoolEventSource.Log;
145 int num2 = 1;
146 switch (pressure)
147 {
148 case Utilities.MemoryPressure.High:
149 num2 = 8;
150 if (bucketSize > 16384)
151 {
152 num2++;
153 }
154 if (Unsafe.SizeOf<T>() > 16)
155 {
156 num2++;
157 }
158 if (Unsafe.SizeOf<T>() > 32)
159 {
160 num2++;
161 }
162 break;
163 case Utilities.MemoryPressure.Medium:
164 num2 = 2;
165 break;
166 }
167 while (_count > 0 && num2-- > 0)
168 {
169 T[] array = _arrays[--_count];
170 _arrays[_count] = null;
171 if (log.IsEnabled())
172 {
173 log.BufferTrimmed(array.GetHashCode(), array.Length, id);
174 }
175 }
176 _millisecondsTimestamp = ((_count > 0) ? (_millisecondsTimestamp + num / 4) : 0);
177 }
178 }
179 }

References System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.LockedStack._arrays, System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.LockedStack._count, System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.LockedStack._millisecondsTimestamp, System.array, and System.Buffers.ArrayPoolEventSource.Log.