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

◆ LocalPopCore()

object System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.LocalPopCore ( )
inlineprivate

Definition at line 218 of file ThreadPoolWorkQueue.cs.

219 {
220 int num;
221 object obj;
222 while (true)
223 {
224 int tailIndex = m_tailIndex;
225 if (m_headIndex >= tailIndex)
226 {
227 return null;
228 }
229 tailIndex--;
230 Interlocked.Exchange(ref m_tailIndex, tailIndex);
231 if (m_headIndex <= tailIndex)
232 {
233 num = tailIndex & m_mask;
234 obj = Volatile.Read(ref m_array[num]);
235 if (obj != null)
236 {
237 break;
238 }
239 continue;
240 }
241 bool lockTaken = false;
242 try
243 {
244 m_foreignLock.Enter(ref lockTaken);
245 if (m_headIndex <= tailIndex)
246 {
247 int num2 = tailIndex & m_mask;
248 object obj2 = Volatile.Read(ref m_array[num2]);
249 if (obj2 != null)
250 {
251 m_array[num2] = null;
252 return obj2;
253 }
254 continue;
255 }
256 m_tailIndex = tailIndex + 1;
257 return null;
258 }
259 finally
260 {
261 if (lockTaken)
262 {
263 m_foreignLock.Exit(useMemoryBarrier: false);
264 }
265 }
266 }
267 m_array[num] = null;
268 return obj;
269 }
void Enter(ref bool lockTaken)
Definition SpinLock.cs:94

References System.Threading.SpinLock.Enter(), System.Threading.Interlocked.Exchange(), System.Threading.SpinLock.Exit(), 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.Read().

Referenced by System.Threading.ThreadPoolWorkQueue.WorkStealingQueue.LocalPop().