Flush callbacks are roughly analogous to the standard C library’s atexit, but flush callback can also be used in other, similar scenarios.
There is no guarantee that a flush callback will be called before a process terminates—either because the plumber is not the original plumber that is flushed by the default exit handler, or because the process is terminated forcibly (e.g., through a custodian shutdown).
Added in version 6.0.1.8 of package base.
procedure
Plumbers have no hierarchy (unlike custodians or inspectors), but a flush callback can be registered in one plumber to call plumber-flush-all with another plumber.
Added in version 6.0.1.8 of package base.
parameter
plumber:plumber?
Added in version 6.0.1.8 of package base.
procedure
(plumber-flush-all plumber)→void?
plumber:plumber?
The flush callbacks to call are collected from plumber before the first one is called. If a flush callback registers a new flush callback, the new one is not called. If a flush callback raises an exception or otherwise escapes, then the remaining flush callbacks are not called.
Added in version 6.0.1.8 of package base.
procedure
v:any/c
Added in version 6.0.1.8 of package base.
procedure
(plumber-add-flush! plumberproc[weak?])→plumber-flush-handle?
plumber:plumber?
The result flush handle represents the registration of the callback, and it can be used with plumber-flush-handle-remove! to unregister the callback.
The given proc is reachable from the flush handle, but if weak? is true, then plumber retains only a weak reference to the result flush handle (and thus proc).
When proc is called as a flush callback, it is passed the same value that is returned by plumber-add-flush! so that proc can conveniently unregister itself. The call of proc is within a continuation barrier.
Added in version 6.0.1.8 of package base.
procedure
(plumber-flush-handle-remove! handle)→void?
handle:plumber-flush-handle?
If the registration represented by handle has been removed already, then plumber-flush-handle-remove! has no effect.
Added in version 6.0.1.8 of package base.