Removed all allocations from the canRestart-method

This commit is contained in:
Viktor Klang 2010-10-08 22:28:39 +02:00
parent b61fd12524
commit bdeaa74493

View file

@ -1032,16 +1032,15 @@ class LocalActorRef private[akka] (
} }
protected[akka] def canRestart(maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Boolean = { protected[akka] def canRestart(maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Boolean = {
(maxNrOfRetries, withinTimeRange) match { if (maxNrOfRetries.isEmpty && withinTimeRange.isEmpty) { //Immortal
case (None, None) => // immortal true
true }
case (Some(maxNrOfRetries), None) => // restrict number of restarts else if (withinTimeRange.isEmpty) { // restrict number of restarts
maxNrOfRetriesCount < maxNrOfRetries maxNrOfRetriesCount < maxNrOfRetries.get
case (None, Some(withinTimeRange)) => // cannot restart within time range since last restart } else { // cannot restart more than N within M timerange
canRestart(Some(1), Some(withinTimeRange)) val maxRetries = if (maxNrOfRetries.isEmpty) 1 else maxNrOfRetries.get //Default to 1, has to match timerange also
case (Some(maxNrOfRetries), Some(withinTimeRange)) => // cannot restart more than N within M timerange !((maxNrOfRetriesCount >= maxRetries) &&
!((maxNrOfRetriesCount >= maxNrOfRetries) && (System.currentTimeMillis - restartsWithinTimeRangeTimestamp < withinTimeRange.get))
(System.currentTimeMillis - restartsWithinTimeRangeTimestamp < withinTimeRange))
} }
} }