コード例 #1
0
ファイル: TransformManyBlock.cs プロジェクト: raj581/Marvin
        void TransformProcess()
        {
            ITargetBlock <TOutput> target;
            TInput input;

            while (messageQueue.TryTake(out input))
            {
                foreach (var item in transformer(input))
                {
                    if ((target = targets.Current) != null)
                    {
                        target.OfferMessage(headers.Increment(), item, this, false);
                    }
                    else
                    {
                        outgoing.AddData(item);
                    }
                }
            }

            if (!outgoing.IsEmpty && (target = targets.Current) != null)
            {
                outgoing.ProcessForTarget(target, this, false, ref headers);
            }
        }
コード例 #2
0
        void TriggerMessage(T1 val1, T2 val2)
        {
            Tuple <T1, T2> tuple = Tuple.Create(val1, val2);
            ITargetBlock <Tuple <T1, T2> > target = targets.Current;

            if (target == null)
            {
                outgoing.AddData(tuple);
            }
            else
            {
                target.OfferMessage(headers.Increment(),
                                    tuple,
                                    this,
                                    false);
            }

            if (!outgoing.IsEmpty && (target = targets.Current) != null)
            {
                outgoing.ProcessForTarget(target, this, false, ref headers);
            }
        }
コード例 #3
0
        void ProcessQueue()
        {
            ITargetBlock <T> target;
            T input;

            while (messageQueue.TryTake(out input))
            {
                if ((target = targets.Current) != null)
                {
                    target.OfferMessage(headers.Increment(), input, this, false);
                }
                else
                {
                    outgoing.AddData(input);
                }
            }

            if (!outgoing.IsEmpty && (target = targets.Current) != null)
            {
                outgoing.ProcessForTarget(target, this, false, ref headers);
            }
        }
コード例 #4
0
ファイル: BatchBlock.cs プロジェクト: claribou/Marvin
        void MakeBatch(ITargetBlock <T[]> target, int size)
        {
            T[] batch = new T[size];
            for (int i = 0; i < size; ++i)
            {
                messageQueue.TryTake(out batch[i]);
            }

            if (target == null)
            {
                outgoing.AddData(batch);
            }
            else
            {
                target.OfferMessage(headers.Increment(), batch, this, false);
            }

            if (!outgoing.IsEmpty && targets.Current != null)
            {
                outgoing.ProcessForTarget(targets.Current, this, false, ref headers);
            }
        }