.map(c -> map.computeIfAbsent(c, ExecControllerBackedScheduler::new))
.orElseGet(() -> {
if (fallback.get() == null) {
int nThreads = Runtime.getRuntime().availableProcessors();
ExecutorService executor = Executors.newFixedThreadPool(nThreads);
Scheduler scheduler = Schedulers.from(executor);
fallback.compareAndSet(null, scheduler);
}
return fallback.get();
});
}