jpmossin / cfuture

Simple composable future

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A simple composable future implementation for Java.

A future can be created either directly by specifying the code to run, or through a promise. For each operation you can specify the executor to run on (and if no executor is specified, ForkJoinPool.commonPool() is used by default)

Promise<String> p = CFutures.promise();
p.success("hello");
p.future().forEach(System.out::println);

CFutures.from(() -> 123)
        .map(e -> e * 2, anExector)  // this map() and the following forEach will run on the given exector  
        .forEach(System.out::println);

CFutures.from(() -> 1 / 0)
        .onFailure(System.out::println);

About

Simple composable future


Languages

Language:Java 100.0%