Beispiel #1
0
            public FastRandom random = new FastRandom(Thread.CurrentThread.ManagedThreadId); // mutable struct, do not copy or make readonly

            public ThreadPoolWorkQueueThreadLocals(ThreadPoolWorkQueue tpq)
            {
                workQueue         = tpq;
                workStealingQueue = new ThreadPoolWorkQueue.WorkStealingQueue();
                ThreadPoolWorkQueue.WorkStealingQueueList.Add(workStealingQueue);
                currentThread = Thread.CurrentThread;
            }
Beispiel #2
0
 internal IEnumerable <IThreadPoolWorkItem> GetLocallyQueuedWorkItems()
 {
     ThreadPoolWorkQueue.WorkStealingQueue wsq = ThreadPoolWorkQueue.ThreadPoolWorkQueueThreadLocals.threadLocals.workStealingQueue;
     if (wsq != null && wsq.m_array != null)
     {
         IThreadPoolWorkItem[] items = wsq.m_array;
         for (int i = 0; i < items.Length; i++)
         {
             IThreadPoolWorkItem item = items[i];
             if (item != null)
             {
                 yield return(item);
             }
         }
     }
 }