-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTestAsyncComplex2.recaf
57 lines (45 loc) · 1.19 KB
/
TestAsyncComplex2.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
50
51
52
53
54
55
56
57
package generated;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import recaf.demo.cps.AsyncFull;
class MyPrinter{
public MyPrinter(){}
public Void print(String msg) {
System.out.println(msg);
return null;
}
}
public class TestAsyncComplex2 {
private static recaf AsyncFull<Integer> alg = new AsyncFull<Integer>() {};
public Void pause(Integer sleeptime) {
try {
new Thread().sleep(sleeptime);
return null;
} catch (InterruptedException ex) {
return null;
}
}
recaff CompletableFuture<Integer> op() {
if (1 < 2) {
pause(2500);
new MyPrinter().print("delayed op");
return 42;
}
return 41;
}
recaff 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 TestAsyncComplex2().op2();
new MyPrinter().print("main");
System.out.println(answer.get());
}
}