@@ -130,7 +130,7 @@ def testSelectorWithReason : Async Unit := do
130130 await task
131131
132132 assert! (← completed.atomically get)
133- assert! (← reasonRef.atomically get) == some .deadline
133+ assert! (← reasonRef.atomically get) == some Std.CancellationReason .deadline
134134
135135#eval testSelectorWithReason.block
136136
@@ -161,32 +161,3 @@ def testMultipleCancellations : Async Unit := do
161161 assert! reason == some .deadline -- First reason should persist
162162
163163#eval testMultipleCancellations.block
164-
165- -- Test cooperative cancellation with reason checking
166- def cooperativeWorkWithReason (token : Std.CancellationToken) (workDone : Std.Mutex Nat) (cancelReason : Std.Mutex (Option CancellationReason)) : Async Unit := do
167- for _ in List.range 50 do
168- if ← token.isCancelled then
169- cancelReason.atomically (set (← token.getCancellationReason))
170- return
171-
172- workDone.atomically (modify (· + 1 ))
173- Async.sleep 10
174-
175- def testCooperativeCancellationWithReason : Async Unit := do
176- let token ← Std.CancellationToken.new
177- let workDone ← Std.Mutex.new 0
178- let cancelReason ← Std.Mutex.new none
179-
180- let workTask ← async (cooperativeWorkWithReason token workDone cancelReason)
181-
182- Async.sleep 150
183- token.cancel .shutdown
184-
185- await workTask
186-
187- let finalCount ← workDone.atomically get
188- assert! finalCount > 0
189- assert! finalCount < 50
190- assert! (← cancelReason.atomically get) == some .shutdown
191-
192- #eval testCooperativeCancellationWithReason.block
0 commit comments