public FixedPriorityScheduler(int threadCount, ThreadPriority priority)
        {
            m_taskQueuesByPriority = new MyConcurrentQueue<Task>[typeof(WorkPriority).GetEnumValues().Length];
            for (int i = 0; i < m_taskQueuesByPriority.Length; ++i)
                m_taskQueuesByPriority[i] = new MyConcurrentQueue<Task>();

            m_hasNoWork = new ManualResetEvent[threadCount];
            m_workers = new Worker[threadCount];
            for (int i = 0; i < threadCount; i++)
            {
                m_workers[i] = new Worker(this, "Parallel " + i, priority);
                m_hasNoWork[i] = m_workers[i].HasNoWork;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor of the worker array.
 /// </summary>
 /// <param name="prioritizedScheduler">Scheduler, owner of this group.</param>
 public WorkerArray(PrioritizedScheduler prioritizedScheduler, int workerArrayIndex, int threadCount, ThreadPriority systemThreadPriority)
 {
     for (int i = 0; i < m_taskQueuesByPriority.Length; i++)
     {
         m_taskQueuesByPriority[i] = new MyConcurrentQueue<Task>(DEFAULT_QUEUE_CAPACITY);
     }
     m_workerArrayIndex = workerArrayIndex;
     m_prioritizedScheduler = prioritizedScheduler;
     m_workers = new Worker[threadCount];
     for (int workerIndex = 0; workerIndex < threadCount; workerIndex++) // initialize workers inside the array
     {
         m_workers[workerIndex] = new Worker(this, "Parallel " + systemThreadPriority + "_" + workerIndex, systemThreadPriority);
     }
 }