Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor childStats requestRestartPermission algorithm #689

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,12 @@ public ChildRestartStats(InternalActorRef child, uint maxNrOfRetriesCount = 0, l
public bool RequestRestartPermission(int maxNrOfRetries, int withinTimeMilliseconds)
{
if (maxNrOfRetries == 0) return false;
var retriesIsDefined = maxNrOfRetries > 0;
var windowIsDefined = withinTimeMilliseconds > 0;
if (retriesIsDefined && !windowIsDefined)
if (withinTimeMilliseconds == 0)
{
_maxNrOfRetriesCount++;
return _maxNrOfRetriesCount <= maxNrOfRetries;
}
if (windowIsDefined)
{
return RetriesInWindowOkay(retriesIsDefined ? maxNrOfRetries : 1, withinTimeMilliseconds);
}
return true;
return RetriesInWindowOkay(maxNrOfRetries, withinTimeMilliseconds);
//retriesWindow match {
// case (Some(retries), _) if retries < 1 ⇒ false
// case (Some(retries), None) ⇒ { maxNrOfRetriesCount += 1; maxNrOfRetriesCount <= retries }
Expand All @@ -84,7 +78,7 @@ private bool RetriesInWindowOkay(int retries, int windowInMilliseconds)
{
windowStart = _restartTimeWindowStartTicks;
}
var windowInTicks = windowInMilliseconds * TimeSpan.TicksPerMillisecond;
var windowInTicks = windowInMilliseconds*TimeSpan.TicksPerMillisecond;
var insideWindow = (now - windowStart) <= windowInTicks;

if (insideWindow)
Expand All @@ -96,7 +90,5 @@ private bool RetriesInWindowOkay(int retries, int windowInMilliseconds)
_restartTimeWindowStartTicks = now;
return true;
}


}
}