Skip to content

Commit

Permalink
Avoid use of deprecated Lwt_main.yield
Browse files Browse the repository at this point in the history
... by replacing them with the almost-equivalent `Lwt.pause`. Promises
constructed in this way have slightly different scheduling behaviour,
but this shouldn't impact the correctness of our code.

See ocsigen/lwt#855 for more details.
  • Loading branch information
craigfe committed Nov 26, 2021
1 parent b3f86f9 commit 04a5bfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/irmin-test/store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ module Make (S : Generic_key) = struct

let rec write fn = function
| 0 -> []
| i -> (fun () -> fn i >>= Lwt_unix.yield) :: write fn (i - 1)
| i -> (fun () -> fn i >>= Lwt.pause) :: write fn (i - 1)

let perform l = Lwt_list.iter_p (fun f -> f ()) l

Expand Down Expand Up @@ -1751,7 +1751,7 @@ module Make (S : Generic_key) = struct
let tag = Fmt.str "tmp-%d-%d" n i in
let* m = S.clone ~src:t ~dst:tag in
S.set_exn m ~info:(infof "update") (k i) (v i) >>= fun () ->
Lwt_unix.yield () >>= fun () ->
Lwt.pause () >>= fun () ->
S.merge_into ~info:(infof "update: multi %d" i) m ~into:t
>>= merge_exn "update: multi")
in
Expand Down Expand Up @@ -1906,7 +1906,7 @@ module Make (S : Generic_key) = struct
let* m = S.clone ~src:t ~dst:tag in
S.set_exn m ~info:(infof "update") (k i) (v i) >>= fun () ->
let* set = S.Head.find m in
Lwt_unix.yield () >>= fun () -> S.Head.test_and_set t ~test ~set))
Lwt.pause () >>= fun () -> S.Head.test_and_set t ~test ~set))
in
let read t =
read
Expand Down
2 changes: 1 addition & 1 deletion src/irmin-test/store_watch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Make (Log : Logs.LOG) (S : Generic_key) = struct

let sleep ?(sleep_t = 0.01) () =
let sleep_t = min sleep_t 1. in
Lwt_unix.yield () >>= fun () -> Lwt_unix.sleep sleep_t
Lwt.pause () >>= fun () -> Lwt_unix.sleep sleep_t

let now_s () = Mtime.Span.to_s (Mtime_clock.elapsed ())

Expand Down

0 comments on commit 04a5bfa

Please sign in to comment.