Function forking_loop

Source
pub fn forking_loop<E: Display, F: FnOnce() -> Result<(), E>>(
    config: LoopWithBackoff,
    job: F,
    until: impl Fn() -> bool,
)
where Error: From<E>,
Expand description

Runs job repeatedly forever by forking off a child, running the job in the child once. In the parent, wait for the child to end, then treat both error returns and crashes / non-0 exits as errors. Restart but back off before retrying, using the given LoopWithBackoff config. Runs until after every run, and returns if it returns true.

Note: must be run while there are no running threads, panics otherwise!