Exemplo n.º 1
0
        public static ISourceBlock <Either <TLeft, IList <TSuccess> > > BufferSafe <TLeft, TSuccess>(this ISourceBlock <Either <TLeft, TSuccess> > source,
                                                                                                     TimeSpan batchTimeout, int batchMaxSize)
        {
            var outputBlock = new BufferBlock <Either <TLeft, IList <TSuccess> > >();

            source.AsObservable()
            .BufferSafe(batchTimeout, batchMaxSize)
            .Subscribe(outputBlock.AsObserver());

            return(outputBlock);
        }
Exemplo n.º 2
0
        public static ISourceBlock <IList <T> > Buffer <T>(this ISourceBlock <T> source,
                                                           TimeSpan batchTimeout, int batchMaxSize)
        {
            var outputBlock = new BufferBlock <IList <T> >();

            source.AsObservable()
            .Buffer(batchTimeout, batchMaxSize)
            .Where(buffer => buffer.Count > 0)
            .Subscribe(outputBlock.AsObserver());

            return(outputBlock);
        }
Exemplo n.º 3
0
 public static IDisposable LinkTo <TOutput, TState>(
     this ISourceBlock <TOutput> source,
     IAgent <TOutput, TState> agent)
 => source.AsObservable().Subscribe(agent.Post);
Exemplo n.º 4
0
 public static IEnumerable <T> ToEnumerable <T>(this ISourceBlock <T> source, CancellationToken cancelToken = default(CancellationToken))
 {
     return(source.AsObservable().ToEnumerable());
 }