You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(* clone streams such that each clone of the original stream raise the same exceptions *)
42
42
letconsume (t, u) s=
43
-
let t' =
44
-
tryEliom_stream.iter (fun_ -> ()) s
43
+
let p, w =Promise.create ()in
44
+
Eliom_lib.fork (fun() ->
45
+
tryPromise.resolve_ok w (Eliom_stream.iter (fun_ -> ()) s)
45
46
withe ->
46
-
(matchPromise.peek t withNone ->Lwt.wakeup_exn u e |_ ->());
47
-
raise e
48
-
in
49
-
Fiber.any
50
-
(List.map
51
-
(funp() -> Promise.await p)
52
-
(* TODO: ciao-lwt: The list [[ Lwt.bind t (fun _ -> Lwt.return_unit); t' ]] is expected to be a list of promises. Use [Fiber.fork_promise] to make a promise. *)
53
-
[ (let _ = t in
54
-
())
55
-
; t' ])
47
+
(matchPromise.peek t withNone ->Promise.resolve_error u e |_ ->());
48
+
Promise.resolve_error w e);
49
+
Eliom_lib.fork (fun() ->
50
+
tryPromise.resolve_ok w (ignore (Promise.await_exn t))
51
+
withe ->Promise.resolve_error w e);
52
+
Promise.await_exn p
56
53
57
54
letclone_exn (t, u) s=
58
55
let s' =Eliom_stream.clone s in
59
56
Eliom_stream.from (fun() ->
60
57
try
61
-
Fiber.any
62
-
(List.map
63
-
(funp() -> Promise.await p)
64
-
(* TODO: ciao-lwt: The list [[ Eliom_stream.get s'; t ]] is expected to be a list of promises. Use [Fiber.fork_promise] to make a promise. *)
65
-
[Eliom_stream.get s'; t])
58
+
let p, w =Promise.create ()in
59
+
Eliom_lib.fork (fun() ->
60
+
tryPromise.resolve_ok w (Eliom_stream.get s')
61
+
withe ->Promise.resolve_error w e);
62
+
Eliom_lib.fork (fun() ->
63
+
tryPromise.resolve_ok w (Promise.await_exn t)
64
+
withe ->Promise.resolve_error w e);
65
+
Promise.await_exn p
66
66
withe ->
67
-
(matchPromise.peek t withNone ->Lwt.wakeup_exn u e |_ ->());
67
+
(matchPromise.peek t withNone ->Promise.resolve_error u e |_ ->());
0 commit comments