This commit is contained in:
Tony Garnock-Jones 2023-10-28 16:32:23 +02:00
parent 6904ef76df
commit 072119d6c0
2 changed files with 6 additions and 6 deletions

View File

@ -21,11 +21,11 @@ public class Forwarder extends Entity {
@Override
public void message_(Turn turn, Object body) {
if (body instanceof IForwarder.SetPeer op) {
this._peer = op.peer();
} else if (body instanceof IForwarder.HandleMessage op) {
if (body instanceof IForwarder.HandleMessage op) {
Ref target = op.hopCount() >= this._nRounds - 1 ? _main : _peer;
turn.message_(target, new IForwarder.HandleMessage(op.hopCount() + 1));
} else if (body instanceof IForwarder.SetPeer op) {
this._peer = op.peer();
}
}
}

View File

@ -54,9 +54,7 @@ public class Main extends Entity {
@Override
public void message_(Turn turn, Object body) {
if (body instanceof IForwarder.SetPeer) {
// Do nothing.
} else if (body instanceof IForwarder.HandleMessage op) {
if (body instanceof IForwarder.HandleMessage op) {
this._remainingToReceive--;
if (this._remainingToReceive == 0) {
double delta = (System.currentTimeMillis() - this._startTime) / 1000.0;
@ -68,6 +66,8 @@ public class Main extends Entity {
delta,
hz));
}
} else if (body instanceof IForwarder.SetPeer) {
// Do nothing.
}
}
}