run_and_stop_if_exists

Function run_and_stop_if_exists 

Source
pub fn run_and_stop_if_exists<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 if it exists.

Using the given lock for synchronisation, this starts the subject 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.