Esempio n. 1
0
 private void CheckPriorityQueue(BlockingPriorityQueue <DispatchQueue> queue)
 {
     while (queue.Count() > MAX_QUEUE_SIZE)
     {
         DispatchQueue dQueue = queue.Dequeue();
         if (dQueue == null)
         {
             return;
         }
         if (dQueue.State == DispatchQueue.QueueState.Idle || dQueue.State == DispatchQueue.QueueState.Disposed)
         {
             dQueue.Dispose();
             Console.WriteLine("Removing queue");
         }
         else
         {
             break;
         }
     }
 }
Esempio n. 2
0
        //private static object _getterLock = new object();
        private DispatchQueue GetDispatchQueue(BlockingPriorityQueue <DispatchQueue> blockerQueue)
        {
            DispatchQueue queue = blockerQueue.Peek();

            if (queue == null || blockerQueue.Count() < MAX_QUEUE_SIZE || (blockerQueue.Count() >= MAX_QUEUE_SIZE && queue.Size() >= MAX_QUEUE_TOLERANCE))
            {
                queue = new DispatchQueue("Concurrent Queue " + blockerQueue.Count(), PriorityForQueue(blockerQueue));
            }
            else
            {
                queue = blockerQueue.Dequeue();
            }
            Console.WriteLine("Queue has " + queue.Size() + " jobs");
            Console.WriteLine(blockerQueue.Count() + " Queues");
            blockerQueue.enqueue(queue);

            lock (_monitorLock)
            {
                Monitor.Pulse(_monitorLock);
            }
            return(queue);
        }