public SubSource(Logic logic, TIn firstElement) : base(logic, "LazySink") { _logic = logic; _stage = logic._stage; SetHandler(new LambdaOutHandler(onPull: () => { Push(firstElement); if (_completed) { SourceComplete(); } else { SwitchToFinalHandler(); } }, onDownstreamFinish: SourceComplete)); logic.SetHandler(_stage.In, new LambdaInHandler( onPush: () => Push(logic.Grab(_stage.In)), onUpstreamFinish: () => { logic.SetKeepGoing(true); _completed = true; }, onUpstreamFailure: SourceFailure)); }
public Logic(LazySink <TIn, TMat> stage, Attributes inheritedAttributes, TaskCompletionSource <TMat> completion) : base(stage.Shape) { _stage = stage; _completion = completion; _decider = new Lazy <Decider>(() => { var attr = inheritedAttributes.GetAttribute <ActorAttributes.SupervisionStrategy>(null); return(attr != null ? attr.Decider : Deciders.StoppingDecider); }); SetHandler(stage.In, this); }