Skip to content
Snippets Groups Projects
Commit 84357fb0 authored by Christian Wulf's avatar Christian Wulf
Browse files

optimized RoundRobinStrategy2

parent aa7b2c93
No related branches found
No related tags found
No related merge requests found
...@@ -29,11 +29,12 @@ public final class RoundRobinStrategy2 implements IDistributorStrategy { ...@@ -29,11 +29,12 @@ public final class RoundRobinStrategy2 implements IDistributorStrategy {
@Override @Override
public <T> boolean distribute(final OutputPort<T>[] outputPorts, final T element) { public <T> boolean distribute(final OutputPort<T>[] outputPorts, final T element) {
int numLoops = outputPorts.length; final int numOutputPorts = outputPorts.length;
int numLoops = numOutputPorts;
boolean success; boolean success;
do { do {
OutputPort<T> outputPort = getNextPortInRoundRobinOrder(outputPorts); final OutputPort<T> outputPort = getNextPortInRoundRobinOrder(outputPorts);
success = outputPort.sendNonBlocking(element); success = outputPort.sendNonBlocking(element);
numLoops--; numLoops--;
if (0 == numLoops) { if (0 == numLoops) {
...@@ -46,7 +47,7 @@ public final class RoundRobinStrategy2 implements IDistributorStrategy { ...@@ -46,7 +47,7 @@ public final class RoundRobinStrategy2 implements IDistributorStrategy {
e.printStackTrace(); e.printStackTrace();
} }
numLoops = outputPorts.length; numLoops = numOutputPorts;
} }
} while (!success); } while (!success);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment