Function spawn_persistent_thread

Source
pub fn spawn_persistent_thread<F>(f: F)
where F: FnOnce() + Send + 'static,
Expand description

Spawns a thread that is guaranteed to run the given closure to completion.

There is a caveat, and that is if the program is killed, this function cannot do anything.

Functionally, this just spawns a thread that will always be joined before the main thread exits, assuming that you call start_unros_runtime.

There is no mechanism to terminate this thread when the runtime is exiting, so that is up to you. If your thread does not terminate affter some time after exiting, a backtrace will be printed, allowing you to identify which of your persistent threads is stuck. As such, this function is expensive to call.