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

Avoid overflow of index #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Avoid overflow of index #9

wants to merge 1 commit into from

Conversation

hseeberger
Copy link

No description provided.

@@ -19,7 +19,7 @@ object ImmutableRoundRobin {

private def activeRoutingBehavior[T](index: Long, workers: Vector[ActorRef[T]]): Behavior[T] =
Actor.immutable[T] { (ctx, msg) =>
workers((index % workers.size).toInt) ! msg
workers(abs(index % workers.size).toInt) ! msg
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a Long so you would have to run for very long before you wrap around (292471 years if the throughput is 1M msg/s)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's all about correctness. And who knows, in the past numeric ranges have been underestimated several times ;-)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, then update to the more correct https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/routing/RoundRobin.scala#L30
otherwise it will not be strict round robin when wrapping around

also update other code: MutableRoundRobin.scala, ImmutableRoundRobin.java, MutableRoundRobin.java

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants