val shutdown :
?force:unit Import.Deferred.t -> int -> unit
shutdown ?force statusinitiates shutdown, which runs all the
at_shutdownfunctions, waits for them to finish, and then exits with the supplied status. The
at_shutdownfunctions can block -- one can use
~forceto forcibly exit (with status 1) if the
at_shutdownfunctions do not finish in a reasonable amount of time.
after (sec 10.).
Repeated calls to
shutdown with the same status will have no effect. Any call to
shutdown with nonzero status will cause that to be the status that is exited with.
A call to
shutdown with different nonzero status from the original call will
val exit :
?force:unit Import.Deferred.t -> int -> 'a Import.Deferred.t
exit ?force statusis
shutdown ?force status; Deferred.never ().
We do not have an exit function that returns a non-deferred:
val exit : ?force:unit Deferred.t -> int -> _
Such a function should not exist, for the same reason that we do not have:
val block : 'a Deferred.t -> 'a
The semantics of such an exit function would allow one to block a running Async job,
and to switch to another one (to run the
at_shutdown handlers), without expressing
that switch in the type system via a
Deferred.t. That would eliminate all the nice
reasoning guarantees that Async gives about concurrent jobs.
val shutting_down :
unit -> [ `No | `Yes of int ]
shutting_down ()reports whether we are currently shutting down, and if so, with what status.
val at_shutdown :
(unit -> unit Import.Deferred.t) -> unit
f ()to be run when
shutdownis called, and for
shutdownto wait until the returned deferred finishes.
shutdown has already been called, then calling
at_shutdown f does nothing.
val don't_finish_before :
unit Import.Deferred.t -> unit
shutdownto wait until
dbecomes determined before finishing. It is like
at_shutdown (fun _ -> d), except it is more efficient, and will not take any space once
dis determined. There is a a single
at_shutdownshared among all deferreds supplied to