File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/java/org/dataloader/orchestration Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 55import java .util .concurrent .LinkedBlockingDeque ;
66import java .util .concurrent .atomic .AtomicReference ;
77import java .util .function .BiFunction ;
8+ import java .util .function .Supplier ;
89
910public class CF <T > {
1011
@@ -71,6 +72,20 @@ public static <T> CF<T> newExceptionally(Throwable e) {
7172 return result ;
7273 }
7374
75+ public static <T > CF <T > supplyAsync (Supplier <T > supplier ,
76+ Executor executor ) {
77+
78+ CF <T > result = new CF <>();
79+ executor .execute (() -> {
80+ try {
81+ result .encodeAndSetResult (supplier .get ());
82+ } catch (Throwable ex ) {
83+ result .encodeAndSetResult (ex );
84+ }
85+ });
86+ return result ;
87+ }
88+
7489
7590 public <U > CF <U > map (BiFunction <? super T , Throwable , ? extends U > fn ) {
7691 CF <U > newResult = new CF <>();
You can’t perform that action at this time.
0 commit comments