1
+ import language .experimental .captureChecking
2
+
1
3
import gears .async .AsyncOperations .*
2
4
import gears .async .default .given
3
5
import gears .async .{Async , AsyncSupport , Future , uninterruptible }
@@ -12,9 +14,9 @@ import boundary.break
12
14
class CancellationBehavior extends munit.FunSuite :
13
15
enum State :
14
16
case Ready
15
- case Initialized ( f : Future [ ? ])
17
+ case Initialized
16
18
case RunningEarly
17
- case Running ( f : Future [ ? ])
19
+ case Running
18
20
case Failed (t : Throwable )
19
21
case Cancelled
20
22
case Completed
@@ -27,19 +29,21 @@ class CancellationBehavior extends munit.FunSuite:
27
29
state match
28
30
case State .Ready =>
29
31
state = State .RunningEarly
30
- case State .Initialized (f) =>
31
- state = State .Running (f)
32
+ case State .Initialized =>
33
+ state = State .Running
32
34
case _ => fail(s " running failed, state is $state" )
33
- def initialize (f : Future [? ]) =
35
+ def initialize (f : Future [? ]^ ) =
34
36
synchronized :
35
37
state match
36
38
case State .Ready =>
37
- state = State .Initialized (f)
39
+ state = State .Initialized
38
40
case State .RunningEarly =>
39
- state = State .Running (f)
41
+ state = State .Running
40
42
case _ => fail(s " initializing failed, state is $state" )
41
43
42
- private def startFuture (info : Info , body : Async ?=> Unit = {})(using a : Async , s : Async .Spawn & a.type ) =
44
+ private def startFuture (info : Info , body : Async ?=> Unit = {})(using a : Async , s : Async .Spawn )(using
45
+ a.type =:= s.type
46
+ ) =
43
47
val f = Future :
44
48
info.run()
45
49
try
@@ -67,7 +71,7 @@ class CancellationBehavior extends munit.FunSuite:
67
71
test(" group cancel" ):
68
72
var x = 0
69
73
Async .blocking:
70
- Async .group:
74
+ Async .group[ Unit ] :
71
75
Future :
72
76
sleep(400 )
73
77
x = 1
0 commit comments