Пример #1
0
        public override async Task Update(FlowBuffer <TInput> inBuf, FlowBuffer <TOutput> outBuf)
        {
            TInput[]  oldContents = inBuf.Contents.ToArray();
            TOutput[] mapped      = Map(oldContents);
            if (ConsumeIf(oldContents, mapped))
            {
                await inBuf.Flow(maxDroplets : inBuf.Capacity).Collect();

                mapped = OnInputTransformed(oldContents, mapped);
                await outBuf.ConsumeFlow(mapped.GetAsyncEnumerator()).Collect();
            }
            else if (inBuf.Full)
            {
                switch (InputBufferStrategy)
                {
                default:
                case InputBufferFullStrategy.FlushToOutput:
                    await inBuf.Drip();

                    await outBuf.ConsumeDroplet(mapped[0]);

                    break;

                case InputBufferFullStrategy.Empty:
                    while (!inBuf.Empty)
                    {
                        await inBuf.Drip();
                    }
                    break;

                case InputBufferFullStrategy.Drip:
                    await inBuf.Drip();

                    break;
                }
            }
        }
Пример #2
0
 public override async Task Update(FlowBuffer <TInput> inBuf, FlowBuffer <TOutput> outBuf)
 {
     await outBuf.ConsumeDroplet(Map(await inBuf.Drip()));
 }