Function run_and_stop

Source
pub fn run_and_stop<S, F, T>(
    subject: &S,
    options: S::Options<'_>,
    lock: UnlockedFile,
    action: F,
) -> Result<T, CoordinateError<S::Error>>
where S: RefUnwindSafe + Subject, F: UnwindSafe + FnOnce() -> T,
Expand description

Perform action in subject.

Using the given lock for synchronisation, this creates the subject if it does not exist, starts it if it’s not running, performs the action, then (maybe) stops the subject again, and finally returns the result of action. If there are other users of the subject – i.e. if an exclusive lock cannot be acquired during the shutdown phase – then the subject is left running.