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 5
5
import java .util .concurrent .LinkedBlockingDeque ;
6
6
import java .util .concurrent .atomic .AtomicReference ;
7
7
import java .util .function .BiFunction ;
8
+ import java .util .function .Supplier ;
8
9
9
10
public class CF <T > {
10
11
@@ -71,6 +72,20 @@ public static <T> CF<T> newExceptionally(Throwable e) {
71
72
return result ;
72
73
}
73
74
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
+
74
89
75
90
public <U > CF <U > map (BiFunction <? super T , Throwable , ? extends U > fn ) {
76
91
CF <U > newResult = new CF <>();
You can’t perform that action at this time.
0 commit comments