Akka.Routing.RoundRobinRoutingLogic.Select C# (CSharp) Method

Select() public method

Picks the next Routee in the collection to receive the message.
public Select ( object message, Routee routees ) : Routee
message object The message that is being routed.
routees Routee A collection of routees to choose from when receiving the .
return Routee
        public override Routee Select(object message, Routee[] routees)
        {
            if (routees == null || routees.Length == 0)
            {
                return Routee.NoRoutee;
            }
            return routees[(Interlocked.Increment(ref _next) & int.MaxValue) % routees.Length];
        }
    }

Usage Example

 public void RoundRobin_should_not_throw_IndexOutOfRangeException_when_counter_wraps_to_be_negative()
 {
     var routees = new[] {Routee.NoRoutee, Routee.NoRoutee, Routee.NoRoutee};
     var routingLogic = new RoundRobinRoutingLogic(int.MaxValue - 5);
     for (var i = 0; i < 10; i++)
     {
         routingLogic.Select(i, routees);
     }
 }
RoundRobinRoutingLogic