Skip to content

Commit 94b7fbc

Browse files
committed
wip
1 parent 48860d9 commit 94b7fbc

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/nl/knaw/dans/lib/util/pollingtaskexec/PollingTaskExecutor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636
@RequiredArgsConstructor
3737
public class PollingTaskExecutor<R> implements Managed {
3838
private final String name;
39-
private final ScheduledExecutorService scheduler;
39+
private final ScheduledExecutorService scheduledExecutorService;
4040
private final Duration pollingInterval;
4141
private final TaskSource<R> taskSource;
4242
private final TaskFactory<R> taskFactory;
4343
private final TaskScheduler taskScheduler;
4444

4545
private ScheduledFuture<?> future;
4646

47-
public PollingTaskExecutor(String name, ScheduledExecutorService scheduler, Duration pollingInterval, TaskSource<R> taskSource, TaskFactory<R> taskFactory) {
48-
this(name, scheduler, pollingInterval, taskSource, taskFactory, new ImmediateTaskScheduler());
47+
public PollingTaskExecutor(String name, ScheduledExecutorService scheduledExecutorService, Duration pollingInterval, TaskSource<R> taskSource, TaskFactory<R> taskFactory) {
48+
this(name, scheduledExecutorService, pollingInterval, taskSource, taskFactory, new ImmediateTaskScheduler());
4949
}
5050

5151
/**
@@ -60,7 +60,7 @@ public PollingTaskExecutor(PollingTaskExecutor<R> other) {
6060
throw new IllegalArgumentException("Cannot copy a running executor");
6161
}
6262
this.name = other.name;
63-
this.scheduler = other.scheduler;
63+
this.scheduledExecutorService = other.scheduledExecutorService;
6464
this.pollingInterval = other.pollingInterval;
6565
this.taskSource = other.taskSource;
6666
this.taskFactory = other.taskFactory;
@@ -70,7 +70,7 @@ public PollingTaskExecutor(PollingTaskExecutor<R> other) {
7070
@Override
7171
public void start() {
7272
long delayMs = Math.max(1L, pollingInterval.toMillis());
73-
future = scheduler.scheduleWithFixedDelay(this::tick, 0, delayMs, TimeUnit.MILLISECONDS);
73+
future = scheduledExecutorService.scheduleWithFixedDelay(this::tick, 0, delayMs, TimeUnit.MILLISECONDS);
7474
log.info("{} started; polling every {}", name, pollingInterval);
7575
}
7676

@@ -79,7 +79,7 @@ public void stop() {
7979
if (future != null) {
8080
future.cancel(false);
8181
}
82-
scheduler.shutdown();
82+
scheduledExecutorService.shutdown();
8383
log.info("{} stopped", name);
8484
}
8585

0 commit comments

Comments
 (0)