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); } }
public static bool Post <TInput> (this ITargetBlock <TInput> target, TInput item) { if (target == null) { throw new ArgumentNullException("target"); } return(target.OfferMessage(globalHeader.Increment(), item, null, false) == DataflowMessageStatus.Accepted); }
public void ProcessForTarget(ITargetBlock <T> target, ISourceBlock <T> source, bool consumeToAccept, ref DataflowMessageHeader headers) { if (target == null) { return; } foreach (var output in GetNonBlockingConsumingEnumerable()) { target.OfferMessage(headers.Increment(), output, source, consumeToAccept); } VerifyCompleteness(); }
void BroadcastProcess () { T input; if (!messageQueue.TryTake (out input) || targets.Current == null) return; foreach (var target in targets) { DataflowMessageHeader header = headers.Increment (); if (cloner != null) vault.StoreMessage (header, input); target.OfferMessage (header, input, this, cloner != null); // TODO: verify if it's the correct semantic T save = input; if (!messageQueue.TryTake (out input)) input = save; } }
void BroadcastProcess() { T input; if (!messageQueue.TryTake(out input) || targets.Current == null) { return; } foreach (var target in targets) { DataflowMessageHeader header = headers.Increment(); if (cloner != null) { vault.StoreMessage(header, input); } target.OfferMessage(header, input, this, cloner != null); } }
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); } }
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); } }
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); } }