package devkit
Module Devkit_core.Lwt_utilSource
Various utilities for use with Lwt.
timely_loop' ?immediate period f run f every period seconds; run immediately if immediate is true.
val timely_loop :
?immediate:bool ->
?wait:unit Lwt.t ->
Time.t ->
(unit -> unit Lwt.t) ->
unit Lwt.ttimely_loop' ?immediate ?wait period f run f every period seconds; run immediately if immediate is true; stop when wait thread terminates.
ensure_order t1 t2 cancel t1 when t2 terminates.
suppress_exn name cleanup t wait for t to terminate, suppress any exception, and call cleanup () afterwards.
same as Lwt.async but also cancels task on Daemon.ShouldExit
idle_check ~interval is a pair (stamp,wait) where you use stamp: unit -> unit to indicate activity, and wait : unit Lwt.t is a promise that resolves if there's been no calls to stamp during an interval.
This is typically used to manage a background task (e.g., periodically fetching data from a remote source) based on whether there is ongoing activity (e.g., whether the data is being used in the UI).