Skip to content

Commit 43f30e7

Browse files
committed
Avoid Fun.protect, because it doesn't know about cancelation
1 parent 2563dff commit 43f30e7

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

test/dune

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
alcotest
4848
domain_shims
4949
picos_std.event
50+
picos_std.finally
5051
picos_std.structured
5152
picos_std.sync
5253
test_scheduler
@@ -248,6 +249,7 @@
248249
alcotest
249250
picos
250251
picos_aux.mpscq
252+
picos_std.finally
251253
picos_std.structured
252254
picos_std.sync
253255
test_scheduler

test/test_structured.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
open Picos_std_event
2+
open Picos_std_finally
23
open Picos_std_structured
34
open Picos_std_sync
45
module Mpscq = Picos_aux_mpscq
@@ -8,11 +9,11 @@ let check join_after ?callstack ?on_return scope =
89
let open Picos in
910
let fiber = Fiber.current () in
1011
let before = Fiber.get_computation fiber in
11-
let finally () =
12+
let check_computation_was_scoped () =
1213
let after = Fiber.get_computation fiber in
1314
assert (before == after)
1415
in
15-
Fun.protect ~finally @@ fun () ->
16+
lastly check_computation_was_scoped @@ fun () ->
1617
join_after ?callstack ?on_return @@ fun bundle ->
1718
let during = Fiber.get_computation fiber in
1819
assert (before != during);

test/test_sync.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
open Picos
22
open Picos_std_event
3-
open Picos_std_sync
3+
open Picos_std_finally
44
open Picos_std_structured
5+
open Picos_std_sync
56

67
let msgs = ref []
78
let empty_bt = Printexc.get_callstack 0
@@ -131,7 +132,7 @@ let test_mutex_and_condition_cancelation () =
131132
let hard_deadline = Unix.gettimeofday () +. 120.0 in
132133

133134
let main i () =
134-
Fun.protect ~finally:(fun () -> Atomic.decr exit) @@ fun () ->
135+
lastly (fun () -> Atomic.decr exit) @@ fun () ->
135136
Test_scheduler.run @@ fun () ->
136137
let state = Random.State.make_self_init () in
137138
let fiber = Fiber.current () in

0 commit comments

Comments
 (0)