lumbermill.internal.Concurrency Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lumbermill-core Show documentation
Show all versions of lumbermill-core Show documentation
Where Logs are cut into Lumber
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));
}
}