Warning: Reason support is experimental. We are looking for beta-tester and contributors.

Module Lwt_gc

module Lwt_gc : sig..end

Interaction with the garbage collector



This module offer a convenient way to add a finaliser launching a thread to a value, without having to use Lwt_unix.run in the finaliser.

val finalise : ('a -> unit Lwt.t) -> 'a -> unit

finalise f x calls f x when x is garbage collected. If f x yields, then Lwt will waits for its termination at the end of the program.

val finalise_or_exit : ('a -> unit Lwt.t) -> 'a -> unit

finalise_or_exit f x call f x when x is garbage collected or (exclusively) when the program exit.