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

net.intelie.pipes.time.DefaultScheduler Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes.time;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class DefaultScheduler implements ClockScheduler {
    private final ScheduledExecutorService executor;
    private final Clock clock;

    public DefaultScheduler() {
        this(Executors.newSingleThreadScheduledExecutor());
    }

    public DefaultScheduler(ScheduledExecutorService executor) {
        this(executor, new SystemClock());
    }

    public DefaultScheduler(ScheduledExecutorService executor, Clock clock) {
        this.executor = executor;
        this.clock = clock;
    }

    @Override
    public SchedulerContext newContext() {
        return new DefaultSchedulerContext(executor, clock);
    }

    public SchedulerContext newContext(long offset) {
        return new DefaultSchedulerContext(executor, clock, offset);
    }

    @Override
    public long now() {
        return clock.now();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy