All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nz.sodium.time.SecondsTimerSystemImpl Maven / Gradle / Ivy

package nz.sodium.time;

class SecondsTimerSystemImpl implements TimerSystemImpl {
    public SecondsTimerSystemImpl() {
        this(new MillisecondsTimerSystemImpl());
    }
    private SecondsTimerSystemImpl(TimerSystemImpl impl) {
        this.t0 = impl.now();
        this.impl = impl;
    }
    private final long t0;
    private final TimerSystemImpl impl;
    public Timer setTimer(Double t, Runnable callback) {
        return impl.setTimer((long)(t * 1000.0) + t0, callback);
    }
    public void runTimersTo(Double now) {
        impl.runTimersTo((long)(now * 1000.0) + t0);
    }
    public Double now() {
        return (double)(impl.now() - t0) / 1000.0;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy