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

◆ LocalPush()

void System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue.LocalPush ( T item,
ref long emptyToNonEmptyListTransitionCount )
inlinepackage

Definition at line 53 of file ConcurrentBag.cs.

54 {
55 bool lockTaken = false;
56 try
57 {
59 int num = _tailIndex;
60 if (num == int.MaxValue)
61 {
62 _currentOp = 0;
63 lock (this)
64 {
66 num = (_tailIndex = num & _mask);
68 }
69 }
71 if (!_frozen && headIndex - (num - 1) < 0 && num - (headIndex + _mask) < 0)
72 {
73 _array[num & _mask] = item;
74 _tailIndex = num + 1;
75 }
76 else
77 {
78 _currentOp = 0;
81 int num2 = num - headIndex;
82 if (num2 >= _mask)
83 {
84 T[] array = new T[_array.Length << 1];
85 int num3 = headIndex & _mask;
86 if (num3 == 0)
87 {
88 Array.Copy(_array, array, _array.Length);
89 }
90 else
91 {
92 Array.Copy(_array, num3, array, 0, _array.Length - num3);
93 Array.Copy(_array, 0, array, _array.Length - num3, num3);
94 }
95 _array = array;
96 _headIndex = 0;
97 num = (_tailIndex = num2);
98 _mask = (_mask << 1) | 1;
99 }
100 _array[num & _mask] = item;
101 _tailIndex = num + 1;
102 if (num2 == 0)
103 {
105 }
107 _stealCount = 0;
108 }
109 checked
110 {
112 }
113 }
114 finally
115 {
116 _currentOp = 0;
117 if (lockTaken)
118 {
119 Monitor.Exit(this);
120 }
121 }
122 }
static int Exchange(ref int location1, int value)
static int Increment(ref int location)
static void Exit(object obj)
static void Enter(object obj)

References System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._addTakeCount, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._array, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._currentOp, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._frozen, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._headIndex, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._mask, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._stealCount, System.Collections.Concurrent.ConcurrentBag< T >.WorkStealingQueue._tailIndex, System.array, System.Array.Copy(), System.Threading.Monitor.Enter(), System.Threading.Interlocked.Exchange(), System.Threading.Monitor.Exit(), System.Threading.Interlocked.Increment(), and System.item.