@@ -181,7 +181,7 @@ public FlattenMerge(int breadth)
181
181
internal sealed class PrefixAndTail < T > : GraphStage < FlowShape < T , ( IImmutableList < T > , Source < T , NotUsed > ) > >
182
182
{
183
183
#region internal classes
184
-
184
+
185
185
private sealed class Logic : TimerGraphStageLogic , IInHandler , IOutHandler
186
186
{
187
187
private const string SubscriptionTimer = "SubstreamSubscriptionTimer" ;
@@ -205,11 +205,11 @@ public Logic(PrefixAndTail<T> stage) : base(stage.Shape)
205
205
Pull ( _stage . _in ) ;
206
206
_tailSource . SetHandler ( new LambdaOutHandler ( onPull : ( ) => Pull ( _stage . _in ) ) ) ;
207
207
} ) ;
208
-
208
+
209
209
SetHandler ( _stage . _in , this ) ;
210
210
SetHandler ( _stage . _out , this ) ;
211
211
}
212
-
212
+
213
213
protected internal override void OnTimer ( object timerKey )
214
214
{
215
215
var materializer = ActorMaterializerHelper . Downcast ( Interpreter . Materializer ) ;
@@ -360,7 +360,7 @@ public PrefixAndTail(int count)
360
360
/// <typeparam name="TKey">TBD</typeparam>
361
361
internal sealed class GroupBy < T , TKey > : GraphStage < FlowShape < T , Source < T , NotUsed > > >
362
362
{
363
- #region Loigc
363
+ #region Logic
364
364
365
365
private sealed class Logic : TimerGraphStageLogic , IInHandler , IOutHandler
366
366
{
@@ -370,7 +370,7 @@ private sealed class Logic : TimerGraphStageLogic, IInHandler, IOutHandler
370
370
private readonly HashSet < SubstreamSource > _substreamsJustStarted = new HashSet < SubstreamSource > ( ) ;
371
371
private readonly Lazy < Decider > _decider ;
372
372
private TimeSpan _timeout ;
373
- private SubstreamSource _substreamWaitingToBePushed ;
373
+ private Option < SubstreamSource > _substreamWaitingToBePushed = Option < SubstreamSource > . None ;
374
374
private Option < TKey > _nextElementKey = Option < TKey > . None ;
375
375
private Option < T > _nextElementValue = Option < T > . None ;
376
376
private long _nextId ;
@@ -379,12 +379,12 @@ private sealed class Logic : TimerGraphStageLogic, IInHandler, IOutHandler
379
379
public Logic ( GroupBy < T , TKey > stage , Attributes inheritedAttributes ) : base ( stage . Shape )
380
380
{
381
381
_stage = stage ;
382
-
382
+
383
383
_decider = new Lazy < Decider > ( ( ) =>
384
384
{
385
385
var attribute = inheritedAttributes . GetAttribute < ActorAttributes . SupervisionStrategy > ( null ) ;
386
386
return attribute != null ? attribute . Decider : Deciders . StoppingDecider ;
387
- } ) ;
387
+ } ) ;
388
388
389
389
SetHandler ( _stage . In , this ) ;
390
390
SetHandler ( _stage . Out , this ) ;
@@ -431,11 +431,12 @@ public void OnPush()
431
431
432
432
public void OnPull ( )
433
433
{
434
- if ( _substreamWaitingToBePushed != null )
434
+ if ( _substreamWaitingToBePushed . HasValue )
435
435
{
436
- Push ( _stage . Out , Source . FromGraph ( _substreamWaitingToBePushed . Source ) ) ;
437
- ScheduleOnce ( _substreamWaitingToBePushed . Key . Value , _timeout ) ;
438
- _substreamWaitingToBePushed = null ;
436
+ var substreamSource = _substreamWaitingToBePushed . Value ;
437
+ Push ( _stage . Out , Source . FromGraph ( substreamSource . Source ) ) ;
438
+ ScheduleOnce ( substreamSource . Key . Value , _timeout ) ;
439
+ _substreamWaitingToBePushed = Option < SubstreamSource > . None ;
439
440
}
440
441
else
441
442
{
@@ -500,7 +501,7 @@ private void Fail(Exception ex)
500
501
FailStage ( ex ) ;
501
502
}
502
503
503
- private bool NeedToPull => ! ( HasBeenPulled ( _stage . In ) || IsClosed ( _stage . In ) || HasNextElement ) ;
504
+ private bool NeedToPull => ! ( HasBeenPulled ( _stage . In ) || IsClosed ( _stage . In ) || HasNextElement || _substreamWaitingToBePushed . HasValue ) ;
504
505
505
506
public override void PreStart ( )
506
507
{
@@ -530,7 +531,7 @@ private void RunSubstream(TKey key, T value)
530
531
{
531
532
Push ( _stage . Out , Source . FromGraph ( substreamSource . Source ) ) ;
532
533
ScheduleOnce ( key , _timeout ) ;
533
- _substreamWaitingToBePushed = null ;
534
+ _substreamWaitingToBePushed = Option < SubstreamSource > . None ;
534
535
}
535
536
else
536
537
{
@@ -628,7 +629,7 @@ public GroupBy(int maxSubstreams, Func<T, TKey> keyFor)
628
629
{
629
630
_maxSubstreams = maxSubstreams ;
630
631
_keyFor = keyFor ;
631
-
632
+
632
633
Shape = new FlowShape < T , Source < T , NotUsed > > ( In , Out ) ;
633
634
}
634
635
@@ -778,7 +779,7 @@ public override void OnDownstreamFinish()
778
779
else
779
780
// Start draining
780
781
if ( ! _logic . HasBeenPulled ( _inlet ) )
781
- _logic . Pull ( _inlet ) ;
782
+ _logic . Pull ( _inlet ) ;
782
783
}
783
784
784
785
public override void OnPush ( )
@@ -1010,7 +1011,7 @@ protected CommandScheduledBeforeMaterialization(ICommand command)
1010
1011
internal class RequestOneScheduledBeforeMaterialization : CommandScheduledBeforeMaterialization
1011
1012
{
1012
1013
public static readonly RequestOneScheduledBeforeMaterialization Instance = new RequestOneScheduledBeforeMaterialization ( RequestOne . Instance ) ;
1013
-
1014
+
1014
1015
private RequestOneScheduledBeforeMaterialization ( ICommand command ) : base ( command )
1015
1016
{
1016
1017
}
@@ -1046,7 +1047,7 @@ private RequestOne()
1046
1047
{
1047
1048
}
1048
1049
}
1049
-
1050
+
1050
1051
internal class Cancel : ICommand
1051
1052
{
1052
1053
public static readonly Cancel Instance = new Cancel ( ) ;
0 commit comments