/// <summary> /// TBD /// </summary> /// <param name="self">TBD</param> /// <param name="waitForUpstream">TBD</param> /// <param name="andThen">TBD</param> /// <exception cref="ArgumentException">TBD</exception> /// <exception cref="IllegalStateException">TBD</exception> public static void InitialPhase(this IPump self, int waitForUpstream, TransferPhase andThen) { if (waitForUpstream < 1) { throw new ArgumentException($"WaitForUpstream must be >= 1 (was {waitForUpstream})"); } if (self.TransferState != NotInitialized.Instance) { throw new IllegalStateException($"Initial state expected NotInitialized, but got {self.TransferState}"); } self.TransferState = new WaitingForUpstreamSubscription(waitForUpstream, andThen); }
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); }
public void NextPhase(TransferPhase phase) => Pumps.NextPhase(this, phase);
public void InitialPhase(int waitForUpstream, TransferPhase andThen) => Pumps.InitialPhase(this, waitForUpstream, andThen);
/// <summary> /// TBD /// </summary> /// <param name="remaining">TBD</param> /// <param name="andThen">TBD</param> public WaitingForUpstreamSubscription(int remaining, TransferPhase andThen) { Remaining = remaining; AndThen = andThen; }
public static void NextPhase(this IPump self, TransferPhase phase) { if (self.TransferState is WaitingForUpstreamSubscription) { var w = (WaitingForUpstreamSubscription) self.TransferState; self.TransferState = new WaitingForUpstreamSubscription(w.Remaining, phase); } else { self.TransferState = phase.Precondition; self.CurrentAction = phase.Action; } }
public static void InitialPhase(this IPump self, int waitForUpstream, TransferPhase andThen) { if (waitForUpstream < 1) throw new ArgumentException($"WaitForUpstream must be >= 1 (was {waitForUpstream})"); if(self.TransferState != NotInitialized.Instance) throw new IllegalStateException($"Initial state expected NotInitialized, but got {self.TransferState}"); self.TransferState = new WaitingForUpstreamSubscription(waitForUpstream, andThen); }
public void NextPhase(TransferPhase phase) => Pumps.NextPhase(this, phase);
public void InitialPhase(int waitForUpstream, TransferPhase andThen) => Pumps.InitialPhase(this, waitForUpstream, andThen);
public WaitingForUpstreamSubscription(int remaining, TransferPhase andThen) { Remaining = remaining; AndThen = andThen; }