private void job() { long start = System.currentTimeMillis(); send(msg); blockingReceive(myTemplate); long time = System.currentTimeMillis() - start; if (!terminated) { System.out.println("Agent " + getLocalName() + " " + cnt + " OK"); totalCoupleTime += time; totalCoupleTime2 += (time * time); if (nIterations > 0 && (++cnt) >= nIterations) { notifyTerminated(totalCoupleTime, totalCoupleTime2); terminated = true; } } if (timeInterval == STEPBYSTEP_TIME_INTERVAL) { notifyReady(); } }
private void job() { if (firstRound) { long time = System.currentTimeMillis(); // Insert the start-time ion the protocol field msg.setProtocol(String.valueOf(time)); firstRound = false; } send(msg); if (timeInterval == STEPBYSTEP_TIME_INTERVAL) { notifyReady(); } }
public void action() { this.prepateTemplate(); if (template == null) msg = myAgent.receive(); else msg = myAgent.receive(template); if (msg != null) { finished = true; handle(msg); return; } long dt = wakeupTime - System.currentTimeMillis(); if (dt > 0) block(dt); else { finished = true; if (msg != null) handle(msg); } }
@Override public void onStart() { wakeupTime = (timeOut < 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeOut); }