Skip to content

Commit edf401b

Browse files
committed
Avoid duplication of Computation.await
1 parent 67eef2c commit edf401b

File tree

6 files changed

+24
-34
lines changed

6 files changed

+24
-34
lines changed

lib/picos/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
(select
88
picos.ml
99
from
10-
(picos_private_ocaml4 -> picos.ocaml4.ml)
11-
(picos_private_ocaml5 -> picos.ocaml5.ml))
10+
(picos_private_ocaml4 -> picos.common.ml)
11+
(picos_private_ocaml5 -> picos.common.ml))
1212
(select
1313
intf.ml
1414
from

lib/picos/ocaml4/picos_private.ml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ end
2828
module Computation = struct
2929
include Picos_private_bootstrap.Computation
3030

31-
let rec await t =
32-
match Atomic.get t with
33-
| Returned value -> value
34-
| Canceled exn_bt -> Exn_bt.raise exn_bt
35-
| Continue _ ->
36-
let trigger = Trigger.create () in
37-
if try_attach t trigger then begin
38-
match Trigger.await trigger with
39-
| None -> await t
40-
| Some exn_bt ->
41-
detach t trigger;
42-
Exn_bt.raise exn_bt
43-
end
44-
else await t
45-
4631
let cancel_after computation ~seconds exn_bt =
4732
if 0.0 <= seconds then
4833
let _ = Fiber.current () in

lib/picos/ocaml5/picos_private.ml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,6 @@ end
5252
module Computation = struct
5353
include Picos_private_bootstrap.Computation
5454

55-
let rec await t =
56-
match Atomic.get t with
57-
| Returned value -> value
58-
| Canceled exn_bt -> Exn_bt.raise exn_bt
59-
| Continue _ ->
60-
let trigger = Picos_private_bootstrap.Trigger.create () in
61-
if try_attach t trigger then begin
62-
match Trigger.await trigger with
63-
| None -> await t
64-
| Some exn_bt ->
65-
detach t trigger;
66-
Exn_bt.raise exn_bt
67-
end
68-
else await t
69-
7055
type _ Effect.t +=
7156
| Cancel_after : {
7257
seconds : float;

lib/picos/picos.common.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include Picos_private
2+
3+
module Computation = struct
4+
include Computation
5+
6+
let block t =
7+
let trigger = Trigger.create () in
8+
if try_attach t trigger then begin
9+
match Trigger.await trigger with
10+
| None -> t
11+
| Some exn_bt ->
12+
detach t trigger;
13+
Exn_bt.raise exn_bt
14+
end
15+
else t
16+
17+
let rec await t =
18+
match Atomic.get t with
19+
| Returned value -> value
20+
| Canceled exn_bt -> Exn_bt.raise exn_bt
21+
| Continue _ -> await (block t)
22+
end

lib/picos/picos.ocaml4.ml

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/picos/picos.ocaml5.ml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)