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
Copy file name to clipboardExpand all lines: src/lib/eliom_bus.client.ml
+68-42Lines changed: 68 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
openLwt.Syntax
1
+
openEio.Std
2
2
3
3
(* Ocsigen
4
4
* http://www.ocsigen.org
@@ -32,31 +32,48 @@ type ('a, 'b) t =
32
32
;stream : 'bLwt_stream.tLazy.t
33
33
;queue : 'aQueue.t
34
34
;mutable max_size : int
35
-
;write : 'alist -> unitLwt.t
36
-
;mutable waiter : unit -> unitLwt.t
37
-
;mutable last_wait : unitLwt.t
35
+
;write : 'alist -> unit
36
+
;mutable waiter : unit -> unit
37
+
;mutable last_wait : unitPromise.t
38
38
;mutable original_stream_available : bool
39
-
;error_h : 'boptionLwt.t*exnLwt.u }
39
+
;error_h : 'boptionPromise.t*exnPromise.u }
40
40
41
41
(* clone streams such that each clone of the original stream raise the same exceptions *)
42
42
letconsume (t, u) s=
43
43
let t' =
44
-
Lwt.catch
45
-
(fun() -> Lwt_stream.iter (fun_ -> ()) s)
46
-
(fune ->
47
-
(matchLwt.state t withLwt.Sleep ->Lwt.wakeup_exn u e |_ ->());
48
-
Lwt.fail e)
44
+
tryLwt_stream.iter (fun_ -> ()) s
45
+
withe ->
46
+
(matchPromise.peek t with
47
+
|None ->
48
+
Promise.resolve_error
49
+
(* TODO: lwt-to-direct-style: This used to be a ['a Lwt.t] is now a [('a, exn) result Promise.t]. Use [resolve_ok] and [await_exn] instead of [resolve] and [await]. *)
50
+
u e
51
+
|_ -> ());
52
+
raise e
49
53
in
50
-
Lwt.choose [Lwt.bind t (fun_ -> Lwt.return_unit); t']
(* TODO: lwt-to-direct-style: This used to be a ['a Lwt.t] is now a [('a, exn) result Promise.t]. Use [resolve_ok] and [await_exn] instead of [resolve] and [await]. *)
0 commit comments