コード例 #1
0
            public override void OnPull()
            {
                var stop = false;

                while (!stop)
                {
                    try
                    {
                        var data = _stage._readData(_blockingStream);
                        if (data.HasValue)
                        {
                            Push(_stage.Out, data.Value);
                        }
                        else
                        {
                            CloseStage();
                        }

                        break;
                    }
                    catch (Exception ex)
                    {
                        var directive = _decider.Value(ex);
                        switch (directive)
                        {
                        case Directive.Stop:
                            _open = false;
                            _stage._close(_blockingStream);
                            FailStage(ex);
                            stop = true;
                            break;

                        case Directive.Restart:
                            RestartState();
                            break;

                        case Directive.Resume:
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
コード例 #2
0
ファイル: Sources.cs プロジェクト: yfer/akka.net
            public Logic(UnfoldResourceSource <TOut, TSource> source, Attributes inheritedAttributes) : base(source.Shape)
            {
                _source = source;
                _inheritedAttributes = inheritedAttributes;
                _decider             = new Lazy <Decider>(() =>
                {
                    var strategy = _inheritedAttributes.GetAttribute <ActorAttributes.SupervisionStrategy>(null);
                    return(strategy != null ? strategy.Decider : Deciders.StoppingDecider);
                });

                SetHandler(source.Out,
                           onPull: () =>
                {
                    var stop = false;
                    while (!stop)
                    {
                        try
                        {
                            var data = source._readData(_blockingStream);
                            if (data.HasValue)
                            {
                                Push(source.Out, data.Value);
                            }
                            else
                            {
                                CloseStage();
                            }

                            break;
                        }
                        catch (Exception ex)
                        {
                            var directive = _decider.Value(ex);
                            switch (directive)
                            {
                            case Directive.Stop:
                                _source._close(_blockingStream);
                                FailStage(ex);
                                stop = true;
                                break;

                            case Directive.Restart:
                                RestartState();
                                break;

                            case Directive.Resume:
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        }
                    }
                },
                           onDownstreamFinish: CloseStage);
            }
コード例 #3
0
ファイル: Sources.cs プロジェクト: yfer/akka.net
 private void RestartState()
 {
     _source._close(_blockingStream);
     _blockingStream = _source._create();
 }