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

io.vertx.up.uca.job.timer.VertxInterval Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.job.timer;

import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.up.annotations.Contract;

public class VertxInterval implements Interval {
    @Contract
    private transient Vertx vertx;

    @Override
    public long startAt(final long delay, final long duration, final Handler actuator) {
        /*
         * In this kind of situation, only predicate is ok
         * Adjust 10 ms for :
         * -- Cannot schedule a timer with delay < 1 ms
         */
        return vertx.setTimer(delay + 10, ignored ->
                vertx.setPeriodic(duration, actuator));
    }

    @Override
    public long startAt(final long duration, final Handler actuator) {
        return vertx.setPeriodic(duration, actuator);
    }

    @Override
    public long startAt(final Handler handler) {
        // Cannot schedule a timer with delay < 1 ms
        return vertx.setTimer(10, handler);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy