protected abstract void submit();
- abstract void cancel();
+ abstract void cancel();
}
private final List<AlignCalcListener> listeners =
new CopyOnWriteArrayList<>();
+ private WorkerManager createManager(AlignCalcWorkerI worker) {
+ if (worker instanceof PollableAlignCalcWorkerI)
+ return new PollableWorkerManager((PollableAlignCalcWorkerI) worker);
+ else
+ return new SimpleWorkerManager(worker);
+ }
@Override
public void registerWorker(AlignCalcWorkerI worker)
{
Objects.requireNonNull(worker);
- WorkerManager manager = (worker instanceof PollableAlignCalcWorkerI) ?
- new PollableWorkerManager((PollableAlignCalcWorkerI) worker) :
- new SimpleWorkerManager(worker);
+ WorkerManager manager = createManager(worker);
registered.putIfAbsent(worker, manager);
startWorker(worker);
}
var manager = registered.get(worker);
if (manager == null)
{
- throw new NoSuchElementException();
+ Cache.log.warn("Starting unregistered worker " + worker);
+ manager = createManager(worker);
}
manager.restart();
}