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

◆ LocalPush()

void System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.LocalPush ( object obj)
inline

Definition at line 100 of file ThreadPoolWorkQueue.cs.

101 {
102 int num = m_tailIndex;
103 if (num == int.MaxValue)
104 {
106 }
107 if (num < m_headIndex + m_mask)
108 {
109 Volatile.Write(ref m_array[num & m_mask], obj);
110 m_tailIndex = num + 1;
111 return;
112 }
113 bool lockTaken = false;
114 try
115 {
116 m_foreignLock.Enter(ref lockTaken);
117 int headIndex = m_headIndex;
118 int num2 = m_tailIndex - m_headIndex;
119 if (num2 >= m_mask)
120 {
121 object[] array = new object[m_array.Length << 1];
122 for (int i = 0; i < m_array.Length; i++)
123 {
124 array[i] = m_array[(i + headIndex) & m_mask];
125 }
126 m_array = array;
127 m_headIndex = 0;
128 num = (m_tailIndex = num2);
129 m_mask = (m_mask << 1) | 1;
130 }
131 Volatile.Write(ref m_array[num & m_mask], obj);
132 m_tailIndex = num + 1;
133 }
134 finally
135 {
136 if (lockTaken)
137 {
138 m_foreignLock.Exit(useMemoryBarrier: false);
139 }
140 }
141 }
void Enter(ref bool lockTaken)
Definition SpinLock.cs:94

References System.array, System.Threading.SpinLock.Enter(), System.Threading.SpinLock.Exit(), System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.LocalPush_HandleTailOverflow(), System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.m_array, System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.m_foreignLock, System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.m_headIndex, System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.m_mask, System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.m_tailIndex, System.obj, and System.Threading.Volatile.Write().