package org.syndicate_lang.actors.example.example2; import java.util.List; // import java.util.Random; public class Forwarder implements IForwarder { private final int _index; private final List _actors; private final IForwarder _main; private final int _nActors; private final int _nRounds; // private final Random _random; public Forwarder(int index, List actors, IForwarder main, int nActors, int nRounds) { this._index = index; this._actors = actors; this._main = main; this._nActors = nActors; this._nRounds = nRounds; // this._random = new Random(); } @Override public void handleMessage(int hopCount) { int index = (this._index + 1) % this._nActors; // int index = _random.nextInt(this._nActors); IForwarder target = hopCount >= this._nRounds - 1 ? _main : this._actors.get(index); target.handleMessage(hopCount + 1); } }