@Override public void fire() { if (!initialized) { initialized = true; beginMs = System.currentTimeMillis(); clock.insertEvent(this, period); return; } long cycles = clock.getCount(); long msGoal = (long) TimeUtil.cyclesToMillis(cycles, clock.getHZ()); while ((System.currentTimeMillis() - beginMs) < msGoal) ; clock.insertEvent(this, period); }
public ThrottleEvent(Simulator s) { clock = s.getClock(); period = clock.getHZ() / 100; }