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

◆ Rent()

T[] System.Buffers.ConfigurableArrayPool< T >.Bucket.Rent ( )
inlinepackage

Definition at line 30 of file ConfigurableArrayPool.cs.

31 {
32 T[][] buffers = _buffers;
33 T[] array = null;
34 bool lockTaken = false;
35 bool flag = false;
36 try
37 {
38 _lock.Enter(ref lockTaken);
39 if (_index < buffers.Length)
40 {
42 buffers[_index++] = null;
43 flag = array == null;
44 }
45 }
46 finally
47 {
48 if (lockTaken)
49 {
50 _lock.Exit(useMemoryBarrier: false);
51 }
52 }
53 if (flag)
54 {
55 array = new T[_bufferLength];
56 ArrayPoolEventSource log = ArrayPoolEventSource.Log;
57 if (log.IsEnabled())
58 {
59 log.BufferAllocated(array.GetHashCode(), _bufferLength, _poolId, Id, ArrayPoolEventSource.BufferAllocatedReason.Pooled);
60 }
61 }
62 return array;
63 }
void Enter(ref bool lockTaken)
Definition SpinLock.cs:94

References System.Buffers.ConfigurableArrayPool< T >.Bucket._bufferLength, System.Buffers.ConfigurableArrayPool< T >.Bucket._buffers, System.Buffers.ConfigurableArrayPool< T >.Bucket._index, System.Buffers.ConfigurableArrayPool< T >.Bucket._lock, System.Buffers.ConfigurableArrayPool< T >.Bucket._poolId, System.array, System.Buffers.ArrayPoolEventSource.BufferAllocated(), System.buffers, System.Threading.SpinLock.Enter(), System.Threading.SpinLock.Exit(), System.Buffers.ConfigurableArrayPool< T >.Bucket.Id, System.Diagnostics.Tracing.EventSource.IsEnabled(), and System.Buffers.ArrayPoolEventSource.Log.

Referenced by System.Buffers.ConfigurableArrayPool< T >.Rent().