-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestAsyncComplex.recaf
49 lines (39 loc) · 1.06 KB
/
TestAsyncComplex.recaf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package generated;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import recaf.demo.cps.Async;
public class TestAsyncComplex {
private static recaf Async<Integer> alg = new Async<Integer>() {};
public static void pause(long sleeptime) {
try {
Thread.sleep(sleeptime);
} catch (InterruptedException ex) { }
}
public static Void print(String msg) {
System.out.println(msg);
return null;
}
recaf CompletableFuture<Integer> op() {
if (1 < 2) {
pause(2500);
print("delayed op");
return 42;
}
return 41;
}
recaf CompletableFuture<Integer> op2() {
if (1 < 2) {
await Integer x = op();
await Integer y = op();
return x + y;
}
pause(5000);
return 41;
}
public static void main(String[] args) throws InterruptedException, ExecutionException{
CompletableFuture<Integer> answer;
answer = new TestAsyncComplex().op2();
print("main");
System.out.println(answer.get());
}
}