コード例 #1
0
 public static void Processing(TimerProcessorStatus status, Queue <TimerProcessorCallBackRequest> queue, IOrderedExpiryItems expiryItems)
 {
     while (queue.Count > 0)
     {
         TimerProcessorCallBackRequest request = queue.Dequeue();
         if (request.Request == TimerProcessorRequest.Add)
         {
             request.ProcessingAdd(status, expiryItems);
         }
         else if (request.Request == TimerProcessorRequest.Remove)
         {
             request.ProcessingRemove(status, expiryItems);
         }
     }
 }
コード例 #2
0
 private void ProcessingRemove(TimerProcessorStatus status, IOrderedExpiryItems expiryItems)
 {
     if (status == TimerProcessorStatus.Operating)
     {
         expiryItems.TryRemove(TimerProcessorItem);
         TrySetResult();
         return;
     }
     if (status == TimerProcessorStatus.Disposing)
     {
         expiryItems.TryRemove(TimerProcessorItem);
         TrySetCanceled();
         return;
     }
     if (status == TimerProcessorStatus.Disposed)
     {
         TrySetDisposed();
         return;
     }
 }
コード例 #3
0
 private void ProcessingAdd(TimerProcessorStatus status, IOrderedExpiryItems expiryItems)
 {
     if (status == TimerProcessorStatus.Operating)
     {
         if (expiryItems.TryAdd(TimerProcessorItem))
         {
             TrySetResult();
         }
         else
         {
             TrySetException($"{nameof(ProcessingAdd)}.TryAdd has failed");
         }
         return;
     }
     if (status == TimerProcessorStatus.Disposing)
     {
         TrySetCanceled();
         return;
     }
     if (status == TimerProcessorStatus.Disposed)
     {
         TrySetDisposed();
     }
 }