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

◆ Return()

override void System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.Return ( T[] array,
bool clearArray = false )
inline

Definition at line 270 of file TlsOverPerCoreLockedStacksArrayPool.cs.

271 {
272 if (array == null)
273 {
274 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
275 }
276 int num = Utilities.SelectBucketIndex(array.Length);
277 ThreadLocalArray[] array2 = t_tlsBuckets ?? InitializeTlsBucketsAndTrimming();
278 bool flag = false;
279 bool flag2 = true;
280 if ((uint)num < (uint)array2.Length)
281 {
282 flag = true;
283 if (clearArray)
284 {
285 Array.Clear(array);
286 }
287 if (array.Length != Utilities.GetMaxSizeForBucket(num))
288 {
289 throw new ArgumentException(SR.ArgumentException_BufferNotFromPool, "array");
290 }
291 ref ThreadLocalArray reference = ref array2[num];
292 T[] array3 = reference.Array;
293 reference = new ThreadLocalArray(array);
294 if (array3 != null)
295 {
296 PerCoreLockedStacks perCoreLockedStacks = _buckets[num] ?? CreatePerCoreLockedStacks(num);
298 }
299 }
300 ArrayPoolEventSource log = ArrayPoolEventSource.Log;
301 if (log.IsEnabled() && array.Length != 0)
302 {
303 log.BufferReturned(array.GetHashCode(), array.Length, Id);
304 if (!(flag && flag2))
305 {
306 log.BufferDropped(array.GetHashCode(), array.Length, Id, flag ? num : (-1), (!flag) ? ArrayPoolEventSource.BufferDroppedReason.OverMaximumSize : ArrayPoolEventSource.BufferDroppedReason.Full);
307 }
308 }
309 }

References System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >._buckets, System.SR.ArgumentException_BufferNotFromPool, System.array, System.Array.Clear(), System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.CreatePerCoreLockedStacks(), System.Buffers.Utilities.GetMaxSizeForBucket(), System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.Id, System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.InitializeTlsBucketsAndTrimming(), System.Buffers.ArrayPoolEventSource.Log, System.Buffers.Utilities.SelectBucketIndex(), System.Buffers.TlsOverPerCoreLockedStacksArrayPool< T >.t_tlsBuckets, and System.ThrowHelper.ThrowArgumentNullException().