Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public void NextPhase(TransferPhase phase) => Pumps.NextPhase(this, phase);
Beispiel #4
0
 public void InitialPhase(int waitForUpstream, TransferPhase andThen)
 => Pumps.InitialPhase(this, waitForUpstream, andThen);
Beispiel #5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="remaining">TBD</param>
 /// <param name="andThen">TBD</param>
 public WaitingForUpstreamSubscription(int remaining, TransferPhase andThen)
 {
     Remaining = remaining;
     AndThen   = andThen;
 }
Beispiel #6
0
 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;
     }
 }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 public void NextPhase(TransferPhase phase) => Pumps.NextPhase(this, phase);
Beispiel #9
0
 public void InitialPhase(int waitForUpstream, TransferPhase andThen)
     => Pumps.InitialPhase(this, waitForUpstream, andThen);
Beispiel #10
0
 public WaitingForUpstreamSubscription(int remaining, TransferPhase andThen)
 {
     Remaining = remaining;
     AndThen = andThen;
 }