Beispiel #1
0
        private void RunBatch()
        {
            try
            {
                var effectiveLimit = !_settings.IsFuzzingMode
                    ? _eventLimit
                    : (ThreadLocalRandom.Current.Next(2) == 0
                        ? (Thread.Yield() ? 1 : 0)
                        : ThreadLocalRandom.Current.Next(2));  // 1 or 0 events to be processed

                Interpreter.Execute(effectiveLimit);
                if (Interpreter.IsCompleted)
                {
                    // Cannot stop right away if not completely subscribed
                    if (CanShutdown)
                    {
                        IsTerminated = true;
                    }
                    else
                    {
                        _waitingForShutdown = true;
                        Materializer.ScheduleOnce(_settings.SubscriptionTimeoutSettings.Timeout, () => Self.Tell(new ActorGraphInterpreter.Abort(this)));
                    }
                }
                else if (Interpreter.IsSuspended && !_resumeScheduled)
                {
                    _resumeScheduled = true;
                    Self.Tell(_resume);
                }
            }
            catch (Exception reason)
            {
                TryAbort(reason);
            }
        }
Beispiel #2
0
        private int RunBatch(int actorEventLimit)
        {
            try
            {
                var usingShellLimit = _shellEventLimit < actorEventLimit;
                var remainingQuota  = _interpreter.Execute(Math.Min(actorEventLimit, _shellEventLimit));

                if (Interpreter.IsCompleted)
                {
                    // Cannot stop right away if not completely subscribed
                    if (CanShutdown)
                    {
                        _interpreterCompleted = true;
                    }
                    else
                    {
                        _waitingForShutdown = true;
                        Materializer.ScheduleOnce(_settings.SubscriptionTimeoutSettings.Timeout,
                                                  () => Self.Tell(new ActorGraphInterpreter.Abort(this)));
                    }
                }
                else if (Interpreter.IsSuspended && !_resumeScheduled)
                {
                    SendResume(!usingShellLimit);
                }

                return(usingShellLimit ? actorEventLimit - _shellEventLimit + remainingQuota : remainingQuota);
            }
            catch (Exception reason)
            {
                TryAbort(reason);
                return(actorEventLimit - 1);
            }
        }