| Crates.io | thread-panic-restart |
| lib.rs | thread-panic-restart |
| version | 0.1.0 |
| created_at | 2025-01-10 14:38:57.683152+00 |
| updated_at | 2025-01-10 14:38:57.683152+00 |
| description | A library to automatically restart a thread after a panic. This is useful for ensuring that threads continue running even in the event of an unexpected error. It provides a simple and effective mechanism to catch panics, restart the thread, and optionally log the error for monitoring and debugging purposes. |
| homepage | |
| repository | https://github.com/ltpp-universe/thread-panic-restart.git |
| max_upload_size | |
| id | 1511307 |
| size | 13,944 |
A library to automatically restart a thread after a panic. This is useful for ensuring that threads continue running even in the event of an unexpected error. It provides a simple and effective mechanism to catch panics, restart the thread, and optionally log the error for monitoring and debugging purposes.
To use this crate, you can run cmd:
cargo add thread-panic-restart
use recoverable_spawn::*;
let msg: &str = "test";
let handle: JoinHandle<()> = recoverable_spawn(move || {
panic!("{}", msg);
});
let _ = handle.join();
let handle: JoinHandle<()> = recoverable_spawn_with_error_handle(
move || {
panic!("{}", msg);
},
|err| {
println!("handle error => {}", err);
},
);
let _ = handle.join();
use recoverable_spawn::*;
let msg: &str = "test";
let handle: JoinHandle<()> = recoverable_spawn_with_error_handle(
move || {
panic!("{}", msg);
},
|err| {
println!("handle error => {}", err);
},
);
let _ = handle.join();
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.
For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.