Exemplo n.º 1
0
        public ParallelWorker(int workerCount)
        {
            if (workerCount < 1)
            {
                throw new ArgumentException(nameof(workerCount));
            }

            this.syncRoot    = new object();
            this.capacity    = workerCount;
            this.idleWorkers = ImmutableHashSet <int> .Empty.Union(Enumerable.Range(0, workerCount));

            this.busyWorkers = ImmutableHashSet <int> .Empty;

            this.waitingWorkItems = new CancellableQueue <WaitingWorkItem>();
        }
Exemplo n.º 2
0
 public IdleDetector()
 {
     syncRoot       = new object();
     referenceCount = 0;
     waiters        = new CancellableQueue <Waiter>();
 }