Example #1
0
            public Logic(FlattenMerge <TGraph, T, TMat> stage) : base(stage.Shape)
            {
                _stage      = stage;
                _outHandler = () =>
                {
                    // could be unavailable due to async input having been executed before this notification
                    if (_q.NonEmpty && IsAvailable(_stage._out))
                    {
                        PushOut();
                    }
                };

                SetHandler(_stage._in, this);
                SetHandler(_stage._out, this);
            }
Example #2
0
            public Logic(FlattenMerge <TGraph, T, TMat> stage) : base(stage.Shape)
            {
                _stage      = stage;
                _outHandler = () =>
                {
                    // could be unavailable due to async input having been executed before this notification
                    if (_q.NonEmpty && IsAvailable(_stage._out))
                    {
                        PushOut();
                    }
                };

                SetHandler(_stage._in,
                           onPush: () =>
                {
                    var source = Grab(_stage._in);
                    AddSource(source);
                    if (ActiveSources < _stage._breadth)
                    {
                        TryPull(_stage._in);
                    }
                },
                           onUpstreamFinish: () =>
                {
                    if (ActiveSources == 0)
                    {
                        CompleteStage();
                    }
                });

                SetHandler(_stage._out,
                           onPull: () =>
                {
                    Pull(_stage._in);
                    SetHandler(_stage._out, _outHandler);
                });
            }