Exemplo n.º 1
0
 private void ProcessQueuedItems(object state)
 {
     try
     {
         for (;;)
         {
             IRequest request;
             if (this.queue.IsEmpty)
             {
                 if (!this.queuedItemSignal.WaitOne(TimeSpan.FromSeconds(10.0)))
                 {
                     break;
                 }
             }
             else if (this.queue.TryDequeue(out request))
             {
                 this.counters.QueueLengthCounter.Decrement();
                 this.currentRequest = request;
                 request.Process();
                 this.counters.ExecutionRateCounter.IncrementBy(1L);
                 DatabaseRequestLog.Write(request);
                 this.currentRequest = null;
             }
         }
     }
     finally
     {
         Interlocked.Exchange(ref this.activeThreads, 0L);
     }
 }
Exemplo n.º 2
0
 public SystemTaskBase GetTask(LoadBalanceWorkload workload, ResourceReservationContext context)
 {
     lock (this.requestQueueLock)
     {
         this.BlockedTaskCount = 0;
         if (this.requests.Count == 0)
         {
             return(null);
         }
         for (int i = 0; i < this.requests.Count; i++)
         {
             IRequest request = this.requests[i];
             if (request.IsBlocked)
             {
                 this.BlockedTaskCount++;
             }
             else if (request.ShouldCancel(this.settings.IdleRunDelay))
             {
                 request.Abort();
                 DatabaseRequestLog.Write(request);
                 this.requests.RemoveAt(i);
                 i--;
             }
             else
             {
                 ResourceKey         obj2;
                 ResourceReservation reservation = context.GetReservation(workload, request.Resources, out obj2);
                 if (reservation != null)
                 {
                     this.requests.RemoveAt(i);
                     return(new LoadBalanceTask(workload, reservation, request));
                 }
                 if (ProcessorResourceKey.Local.Equals(obj2))
                 {
                     this.BlockedTaskCount = this.requests.Count;
                     break;
                 }
                 this.BlockedTaskCount++;
             }
         }
     }
     return(null);
 }
Exemplo n.º 3
0
 protected override TaskStepResult Execute()
 {
     this.request.Process();
     DatabaseRequestLog.Write(this.request);
     return(TaskStepResult.Complete);
 }