Exemplo n.º 1
0
 private static ITask DequeuePendingItem(List <ReceiverTask> receivers)
 {
     foreach (ReceiverTask current in receivers)
     {
         ITask task = Interleave.DequeuePendingItem(current, 1);
         if (task != null)
         {
             return(task);
         }
     }
     return(null);
 }
Exemplo n.º 2
0
 public ITask TryDequeuePendingTask(InterleaveReceivers receiverMask)
 {
     lock (_mutexBranches)
     {
         if ((receiverMask & InterleaveReceivers.Exclusive) > (InterleaveReceivers)0)
         {
             ITask result = Interleave.DequeuePendingItem(_mutexBranches);
             return(result);
         }
         if ((receiverMask & InterleaveReceivers.Concurrent) > (InterleaveReceivers)0)
         {
             ITask result = Interleave.DequeuePendingItem(_concurrentBranches);
             return(result);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        public ITask TryDequeuePendingTask(ReceiverTask receiver, int queueDepthMin)
        {
            if (receiver == null)
            {
                throw new ArgumentNullException("receiver");
            }
            if (!(receiver.ArbiterContext is InterleaveReceiverContext))
            {
                throw new ArgumentException("receiver", Resource1.InterleaveInvalidReceiverTaskArgumentForTryDequeuePendingItems);
            }
            if (queueDepthMin <= 0)
            {
                throw new ArgumentOutOfRangeException("queueDepthMin");
            }
            ITask result;

            lock (_mutexBranches)
            {
                result = Interleave.DequeuePendingItem(receiver, queueDepthMin);
            }
            return(result);
        }
Exemplo n.º 4
0
        public void CombineWith(Interleave child)
        {
            if (_state == ArbiterTaskState.Done)
            {
                throw new InvalidOperationException("Parent Interleave context is no longer active");
            }
            List <ReceiverTask> list  = null;
            List <ReceiverTask> list2 = null;

            lock (child._mutexBranches)
            {
                list  = new List <ReceiverTask>(child._mutexBranches);
                list2 = new List <ReceiverTask>(child._concurrentBranches);
                foreach (ReceiverTask current in list2)
                {
                    if (current.State == ReceiverTaskState.Onetime)
                    {
                        throw new InvalidOperationException("Concurrent Receivers must be Reissue");
                    }
                }
                child._mutexBranches      = null;
                child._concurrentBranches = null;
            }
            lock (_mutexBranches)
            {
                _mutexBranches.AddRange(list);
                _concurrentBranches.AddRange(list2);
            }
            list.ForEach(delegate(ReceiverTask receiver)
            {
                receiver.Arbiter = this;
            });
            list2.ForEach(delegate(ReceiverTask receiver)
            {
                receiver.Arbiter = this;
            });
        }