forked from JoshOrndorff/LearnRholangByExample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abortableLaunch.rho
40 lines (38 loc) · 949 Bytes
/
abortableLaunch.rho
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
new rocketFactory in {
// When a new rocket is setup, a launch capability for each for each operator is passed in
contract rocketFactory(aliceLaunch, bobLaunch, ack) = {
new aliceReadyCh, bobReadyCh in {
// Start out neither ready
aliceReadyCh!(false)|
bobReadyCh!(false)|
contract aliceLaunch(ack) = {
new aliceAbort in {
for (_ <- aliceReadyCh) {
aliceReadyCh!(true)
}
|
contract aliceAbort(ack) = {
for(_ <- aliceReadyCh) {
aliceReadyCh!(false)
|
ack!(Nil)
}
}
|
ack!(*aliceAbort)
}
}
|
Nil // Bob contract goes here
| ack!(Nil)
}
}
|
// Make a new rocket to test
new aliceLaunch, bobLaunch, ack in {
rocketFactory!(*aliceLaunch, *bobLaunch, *ack)|
for (_ <- ack){
Nil // Tests go here
}
}
}