pub fn recoverable_spawn<F>(function: F) -> JoinHandle<()>where
F: RecoverableFunction,Expand description
Spawns a new thread to run the provided function function in a recoverable manner.
If the function function panics during execution, the panic will be caught, and the thread
will terminate without crashing the entire program.
§Parameters
function: A function of typefunctionto be executed in the spawned thread. It must implementFnOnce(),Send,Sync, and'statictraits.FnOnce(): The function is callable with no arguments and no return value.Send: The function can be safely transferred across thread boundaries.Sync: The function can be shared across threads safely.'static: The function does not contain references to non-static data (i.e., data that lives beyond the function’s scope).
§Returns
- A
JoinHandle<()>representing the spawned thread. The thread can be joined later to wait for its completion.
§Panics
- This function itself will not panic, but the function
functioncould panic during execution. The panic will be caught, preventing the program from crashing.