Add few Lwt.pause to give an opportunity for other processes to run

This commit is contained in:
Calascibetta Romain 2024-02-11 12:35:57 +01:00
parent 033c6bb800
commit 0832c0fde9

View file

@ -243,11 +243,11 @@ let pack t ~commit stream =
go encoder go encoder
| `End -> Lwt.return_unit in | `End -> Lwt.return_unit in
let encoder = Carton.Enc.N.dst encoder b.o 0 (Bigstringaf.length b.o) in let encoder = Carton.Enc.N.dst encoder b.o 0 (Bigstringaf.length b.o) in
go encoder in Lwt.pause () >>= fun () -> go encoder in
let rec go idx = let rec go idx =
if idx < Array.length targets if idx < Array.length targets
then encode_target idx >>= fun () -> go (succ idx) then encode_target idx >>= fun () -> go (succ idx)
else Lwt.return_unit in else Lwt.pause () in
go 0 >>= fun () -> go 0 >>= fun () ->
let hash = SHA1.get !ctx in let hash = SHA1.get !ctx in
stream (Some (SHA1.to_raw_string hash)) ; stream (Some (SHA1.to_raw_string hash)) ;