Beispiel #1
0
        protected override IStream <TOut> CreateOutputStream(CrossApplyArgs <TInMain, TInToApply, TValueIn, TValueOut, TOut> args)
        {
            var ob = args.MainStream.Observable.CombineWithLatest(args.StreamToApply.Observable.First(), (m, a) => new Tuple <TInMain, TInToApply>(m, a));

            if (args.NoParallelisation)
            {
                return(base.CreateUnsortedStream(ob.MultiMap <Tuple <TInMain, TInToApply>, TOut>((Tuple <TInMain, TInToApply> i, Action <TOut> push) =>
                {
                    var inputValue = args.GetValueIn(i.Item1, i.Item2);
                    Action <TValueOut> newPush = (TValueOut e) => push(args.GetValueOut(e, i.Item1, i.Item2));
                    args.ValuesProvider(inputValue, i.Item2, newPush);
                })));
            }
            else
            {
                var synchronizer = new Synchronizer();
                return(base.CreateUnsortedStream(ob.FlatMap(i => new DeferredPushObservable <TOut>(push =>
                {
                    var inputValue = args.GetValueIn(i.Item1, i.Item2);
                    Action <TValueOut> newPush = (TValueOut e) => push(args.GetValueOut(e, i.Item1, i.Item2));
                    using (synchronizer.WaitBeforeProcess())
                        args.ValuesProvider(inputValue, i.Item2, newPush);
                })
                                                            )));
            }
        }
        protected override IStream <TOut> CreateOutputStream(CrossApplyArgs <TInMain, TInToApply, TValueIn, TValueOut, TOut> args)
        {
            var ob = args.MainStream.Observable.CombineWithLatest(args.StreamToApply.Observable, (m, a) => new { Main = m, Apply = a });

            return(base.CreateUnsortedStream(ob.FlatMap(i =>
            {
                var def = args.ValuesProvider.PushValues(i.Apply, args.GetValueIn(i.Main, i.Apply));
                return new DeferedWrapperPushObservable <TOut>(def.Map(o => args.GetValueOut(o, i.Main, i.Apply)), def.Start);
            })));
        }
Beispiel #3
0
 public CrossApplyStreamNode(string name, CrossApplyArgs <TInMain, TInToApply, TValueIn, TValueOut, TOut> args) : base(name, args)
 {
 }