Skip to content

Commit d1b0c8f

Browse files
committed
Automatic changes done with lwt-to-direct-style
1 parent 682e7e3 commit d1b0c8f

35 files changed

+796
-839
lines changed

src/baselib/ocsigen_cache.ml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
open Eio.Std
2+
13
(* Ocsigen
24
* Copyright (C) 2009
35
*
@@ -22,8 +24,6 @@
2224
@author Raphaël Proust (adding timers)
2325
*)
2426

25-
open Lwt.Infix
26-
2727
module Dlist : sig
2828
type 'a t
2929
type 'a node
@@ -120,7 +120,7 @@ end = struct
120120
; mutable finaliser_after : 'a node -> unit
121121
; time_bound : time_bound option }
122122

123-
and time_bound = {timer : float; mutable collector : unit Lwt.t option}
123+
and time_bound = {timer : float; mutable collector : unit Promise.t option}
124124

125125
(* Checks (by BY):
126126
@@ -214,7 +214,7 @@ end = struct
214214
| None -> assert false (* collection is set to None and collector to Some *)
215215
| Some t ->
216216
let duration = t -. Unix.gettimeofday () in
217-
if duration <= 0. then Lwt.return () else Lwt_unix.sleep duration
217+
if duration <= 0. then () else Eio_unix.sleep duration
218218

219219
(* a function to set the collector. *)
220220
let rec update_collector r =
@@ -227,11 +227,10 @@ end = struct
227227
| Some n ->
228228
t.collector <-
229229
Some
230-
( sleep_until n.collection >>= fun () ->
231-
collect r n;
232-
t.collector <- None;
233-
update_collector r;
234-
Lwt.return () ))
230+
(sleep_until n.collection;
231+
collect r n;
232+
t.collector <- None;
233+
update_collector r))
235234

236235
(* Add a node that do not belong to any list to a list.
237236
The fields [succ] and [prev] are overridden.
@@ -399,7 +398,7 @@ functor
399398
type t =
400399
{ mutable pointers : A.key Dlist.t
401400
; mutable table : (A.value * A.key Dlist.node) H.t
402-
; finder : A.key -> A.value Lwt.t
401+
; finder : A.key -> A.value
403402
; clear : unit -> unit
404403
(* This function clears the cache. It is put inside the
405404
cache structure so that it is garbage-collected only when the cache
@@ -460,14 +459,14 @@ functor
460459
let size c = Dlist.size c.pointers
461460

462461
let find cache k =
463-
try Lwt.return (find_in_cache cache k)
462+
try find_in_cache cache k
464463
with Not_found ->
465-
cache.finder k >>= fun r ->
464+
let r = cache.finder k in
466465
(try
467466
(* it may have been added during cache.finder *)
468467
ignore (find_in_cache cache k : A.value)
469468
with Not_found -> add_no_remove cache k r);
470-
Lwt.return r
469+
r
471470

472471
class cache f ?timer size_c =
473472
let c = create f ?timer size_c in

src/baselib/ocsigen_cache.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ module Make : functor
5353
Using [timer] allow one to create a cache
5454
bounded both in space and time. It is to be noted that real lifespan
5555
of values is always slightly greater than [timer]. *)
56-
class cache : (A.key -> A.value Lwt.t) -> ?timer:float -> int -> object
57-
method find : A.key -> A.value Lwt.t
56+
class cache : (A.key -> A.value) -> ?timer:float -> int -> object
57+
method find : A.key -> A.value
5858
(** Find the cached value associated to the key, or binds this
5959
value in the cache using the function [finder] passed as argument
6060
to [create], and returns this value *)

src/baselib/ocsigen_lib.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ module Ip_address = struct
2626

2727
let get_inet_addr ?(v6 = false) host =
2828
let rec aux = function
29-
| [] -> Lwt.fail No_such_host
30-
| {Unix.ai_addr = Unix.ADDR_INET (inet_addr, _); _} :: _ ->
31-
Lwt.return inet_addr
29+
| [] -> raise No_such_host
30+
| {Unix.ai_addr = Unix.ADDR_INET (inet_addr, _); _} :: _ -> inet_addr
3231
| _ :: l -> aux l
3332
in
3433
let options =
35-
[ (if v6
36-
then Lwt_unix.AI_FAMILY Lwt_unix.PF_INET6
37-
else Lwt_unix.AI_FAMILY Lwt_unix.PF_INET) ]
34+
[ (if v6 then Unix.AI_FAMILY Unix.PF_INET6 else Unix.AI_FAMILY Unix.PF_INET)
35+
]
3836
in
39-
Lwt.bind (Lwt_unix.getaddrinfo host "" options) aux
37+
aux
38+
(Unix.getaddrinfo
39+
(* TODO: lwt-to-direct-style: This call to [Unix.getaddrinfo] was [Lwt_unix.getaddrinfo] before the rewrite. *)
40+
host "" options)
4041
end
4142

4243
(*****************************************************************************)

src/baselib/ocsigen_lib.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module String : module type of String_base
3939
module Ip_address : sig
4040
exception No_such_host
4141

42-
val get_inet_addr : ?v6:bool -> string -> Unix.inet_addr Lwt.t
42+
val get_inet_addr : ?v6:bool -> string -> Unix.inet_addr
4343
end
4444

4545
module Filename : sig

src/baselib/ocsigen_lib_base.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ exception Ocsigen_Request_too_long
2323

2424
external id : 'a -> 'a = "%identity"
2525

26-
include Lwt.Infix
27-
2826
let ( !! ) = Lazy.force
2927
let ( |> ) x f = f x
3028
let ( @@ ) f x = f x
@@ -47,8 +45,7 @@ type yesnomaybe = Yes | No | Maybe
4745
type ('a, 'b) leftright = Left of 'a | Right of 'b
4846

4947
let advert =
50-
"Page generated by OCaml with Ocsigen.
51-
See http://ocsigen.org/ and http://caml.inria.fr/ for information"
48+
"Page generated by OCaml with Ocsigen.\nSee http://ocsigen.org/ and http://caml.inria.fr/ for information"
5249

5350
(*****************************************************************************)
5451

src/baselib/ocsigen_lib_base.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ exception Input_is_too_large
2626
exception Ocsigen_Bad_Request
2727
exception Ocsigen_Request_too_long
2828

29-
include module type of Lwt.Infix
30-
3129
val ( !! ) : 'a Lazy.t -> 'a
3230
val ( |> ) : 'a -> ('a -> 'b) -> 'b
3331
val ( @@ ) : ('a -> 'b) -> 'a -> 'b

0 commit comments

Comments
 (0)