net.intelie.pipes.time.DefaultScheduler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
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();
}
}