public GroupByProcessorImpl(ActorMaterializerSettings settings, int maxSubstreams, Func <object, object> keyFor) : base(settings) { _maxSubstreams = maxSubstreams; _keyFor = keyFor; _decider = settings.SupervisionDecider; var waitFirst = new TransferPhase(PrimaryInputs.NeedsInput.And(PrimaryOutputs.NeedsDemand), () => { var element = PrimaryInputs.DequeueInputElement(); object key; if (TryKeyFor(element, out key)) { NextPhase(OpenSubstream(element, key)); } }); _waitNext = new TransferPhase(PrimaryInputs.NeedsInput, () => { var element = PrimaryInputs.DequeueInputElement(); object key; if (TryKeyFor(element, out key)) { SubstreamOutput substream; if (_keyToSubstreamOutput.TryGetValue(key, out substream)) { if (substream.IsOpen) { NextPhase(DispatchToSubstream(element, substream)); } } else if (PrimaryOutputs.IsOpen) { NextPhase(OpenSubstream(element, key)); } } }); InitialPhase(1, waitFirst); }
/// <summary> /// TBD /// </summary> /// <param name="settings">TBD</param> /// <param name="onTerminated">TBD</param> public FanoutProcessorImpl(ActorMaterializerSettings settings, Action onTerminated) : base(settings) { PrimaryOutputs = new FanoutOutputs <T, TStreamBuffer>(settings.MaxInputBufferSize, settings.InitialInputBufferSize, Self, this, AfterFlush); _onTerminated = onTerminated; var running = new TransferPhase(PrimaryInputs.NeedsInput.And(PrimaryOutputs.NeedsDemand), () => PrimaryOutputs.EnqueueOutputElement(PrimaryInputs.DequeueInputElement())); InitialPhase(1, running); }