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

lumbermill.internal.Concurrency Maven / Gradle / Ivy

The newest version!
package lumbermill.internal;

import lumbermill.api.Observables;
import rx.Observable;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Supplier;

public class Concurrency {

    private static ExecutorService IO_EXECUTOR = Executors.newCachedThreadPool();

    private static   CompletableFuture runOnIO(Supplier supplier) {
        return CompletableFuture.supplyAsync(supplier, IO_EXECUTOR);
    }

    public static  Observable ioJob(Supplier supplier) {
        return Observables.observe(runOnIO(supplier));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy