Exemplo n.º 1
0
        protected override IStream <TOut> CreateOutputStream(SubProcessArgs <TIn, TOut> args)
        {
            if (this.ExecutionContext is GetDefinitionExecutionContext)
            {
                var inputStream  = new SingleStream <TIn>(new SubNodeWrapper(this), PushObservable.FromSingle(default(TIn), args.Stream.Observable.CancellationToken));
                var outputStream = args.SubProcess(inputStream);
                // this.ExecutionContext.AddNode(this, outputStream.Observable);
            }
            Synchronizer synchronizer     = new Synchronizer(args.NoParallelisation);
            var          outputObservable = args.Stream.Observable
                                            .FlatMap((i, ct) =>
            {
                // TODO: Solve bug here (this operator makes the process freezing))

                EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
                var inputStream            = new SingleStream <TIn>(new SubNodeWrapper(this), PushObservable.FromSingle(i, waitHandle, ct));
                var outputStream           = args.SubProcess(inputStream);
                // this.ExecutionContext.AddNode(this, outputStream.Observable);
                IDisposable awaiter = null;
                outputStream.Observable.Subscribe(j => { }, () => awaiter?.Dispose());
                return(new DeferredWrapperPushObservable <TOut>(outputStream.Observable, () =>
                {
                    awaiter = synchronizer.WaitBeforeProcess();
                    waitHandle.Set();
                }, null, ct));
            });

            return(base.CreateUnsortedStream(outputObservable));
        }
Exemplo n.º 2
0
 public SubProcessStreamNode(string name, SubProcessArgs <TIn, TOut> args) : base(name, args)
 {
 }