Beispiel #1
0
 public bool Evaluate(ReceiverTask receiver, ref ITask deferredTask)
 {
     if (_state == ArbiterTaskState.Done)
     {
         deferredTask = null;
         return(false);
     }
     lock (_mutexBranches)
     {
         if (((InterleaveReceiverContext)receiver.ArbiterContext).ReceiverGroup == InterleaveReceivers.Teardown && receiver.State == ReceiverTaskState.Onetime)
         {
             _state = ArbiterTaskState.Done;
             object obj = Interlocked.CompareExchange(ref _final, deferredTask, null);
             if (obj != null)
             {
                 deferredTask = null;
                 return(false);
             }
         }
         bool flag2 = ((InterleaveReceiverContext)receiver.ArbiterContext).ReceiverGroup != InterleaveReceivers.Concurrent;
         bool flag3 = Arbitrate(flag2);
         if (flag2)
         {
             if (flag3)
             {
                 if (_final == deferredTask)
                 {
                     _final       = null;
                     deferredTask = new Task <ITask>(deferredTask, new Handler <ITask>(Cleanup));
                 }
                 else
                 {
                     deferredTask.ArbiterCleanupHandler = new Handler(ExclusiveFinalizer);
                 }
             }
             else
             {
                 if (deferredTask != _final)
                 {
                     ((InterleaveReceiverContext)receiver.ArbiterContext).PendingItems.Enqueue(new Tuple <ITask, ReceiverTask>(deferredTask, receiver));
                 }
                 deferredTask = null;
             }
             if (deferredTask != null)
             {
                 receiver.TaskQueue.Enqueue(deferredTask);
                 deferredTask = null;
             }
         }
         else if (flag3)
         {
             deferredTask.ArbiterCleanupHandler = new Handler(ConcurrentFinalizer);
         }
         else
         {
             ((InterleaveReceiverContext)receiver.ArbiterContext).PendingItems.Enqueue(new Tuple <ITask, ReceiverTask>(deferredTask, receiver));
             deferredTask = null;
         }
     }
     return(true);
 }
Beispiel #2
0
 public IEnumerator<ITask> Execute()
 {
     lock (_lock) {
         foreach (var rt in branches)
             rt.Arbiter = this;
         state = ArbiterTaskState.Active;
     }
     return null;
 }
Beispiel #3
0
 public IEnumerator <ITask> Execute()
 {
     _state = ArbiterTaskState.Active;
     Register();
     return(null);
 }
Beispiel #4
0
 public bool Evaluate(ReceiverTask receiver, ref ITask deferredTask)
 {
     lock (_lock) {
         if (done) {
             deferredTask = null;
             return false;
         } else {
             state = ArbiterTaskState.Done;
             deferredTask = new Task<ITask> (deferredTask, this.Finish);
             done = true;
             return true;
         }
     }
 }