Example #1
0
        /// <summary>
        /// Creates a target that takes a group of items.
        /// </summary>
        /// <typeparam name="TIn"></typeparam>
        /// <param name="target"></param>
        /// <param name="boundedCapacity"></param>
        /// <returns></returns>
        public ActionBlock <IDataflowMessage <TIn>[]> CreateTargetBatched <TIn>(ITargetBatched <TIn> target, int boundedCapacity = -1)
        {
            ActionBlock <IDataflowMessage <TIn>[]> block = null;
            var targetFunc = target
                             .WithExceptionHandler(m_LogAgent, this)
                             .WithLogging(m_LogAgent)
                             .WithWorkloadStatistics(boundedCapacity, () => block.InputCount, m_ctx, this.m_DfnGuid, m_Cts.Token);

            if (m_LogStatistics)
            {
                targetFunc = targetFunc.WithStatistics(m_LogAgent);
                m_StatisticsLoggers.Add((IStatisticsLogger)targetFunc);
            }

            block = new ActionBlock <IDataflowMessage <TIn>[]>(
                targetFunc
                .AsFunction(), CreateDefaultExecutionOptions(boundedCapacity));
            RecordTask(block);
            return(block);
        }
Example #2
0
 public static Action <TIn[]> AsFunction <TIn>(this ITargetBatched <TIn> target)
 {
     return(target.Push);
 }
Example #3
0
 public ExceptionDecoratorTargetBatched(ITargetBatched <TIn> decoratedTarget, ILogAgent logAgent, ICancelNetwork cancel)
 {
     m_DecoratedTarget = decoratedTarget;
     m_LogAgent        = logAgent;
     m_Cancel          = cancel;
 }
Example #4
0
 public static ITargetBatchedFunctor <TIn> WithExceptionHandler <TIn>(this ITargetBatched <TIn> decoratedTarget, ILogAgent log, ICancelNetwork cancel)
 {
     return(new ExceptionDecoratorTargetBatched <TIn>(decoratedTarget, log, cancel));
 }