public Logic(MonitorFlow <T> stage, FLowMonitorImpl <T> monitor) : base(stage.Shape) { _stage = stage; _monitor = monitor; SetHandler(stage.In, stage.Out, this); }
public Logic(MonitorFlow <T> stage, FLowMonitorImpl <T> monitor) : base(stage.Shape) { SetHandler(stage.In, onPush: () => { var message = Grab(stage.In); Push(stage.Out, message); monitor.Value = message is FlowMonitor.IStreamState ? new FlowMonitor.Received <T>(message) : (object)message; }, onUpstreamFinish: () => { CompleteStage(); monitor.Value = FlowMonitor.Finished.Instance; }, onUpstreamFailure: cause => { FailStage(cause); monitor.Value = new FlowMonitor.Failed(cause); }); SetHandler(stage.Out, onPull: () => Pull(stage.In), onDownstreamFinish: () => { CompleteStage(); monitor.Value = FlowMonitor.Finished.Instance; }); }