| Crates.io | recoverable-thread-pool |
| lib.rs | recoverable-thread-pool |
| version | 2.4.4 |
| created_at | 2025-01-10 00:39:00.358459+00 |
| updated_at | 2025-08-02 07:07:01.858289+00 |
| description | A thread pool that supports automatic recovery from panics, allowing threads to restart after a panic. Useful for resilient and fault-tolerant concurrency in network and web programming. |
| homepage | |
| repository | https://github.com/crates-dev/recoverable-thread-pool.git |
| max_upload_size | |
| id | 1510807 |
| size | 29,352 |
A thread pool that supports automatic recovery from panics, allowing threads to restart after a panic. Useful for resilient and fault-tolerant concurrency in network and web programming.
To use this crate, you can run cmd:
cargo add recoverable-thread-pool
use recoverable_thread_pool::*;
use std::{thread::sleep, time::Duration};
let thread_pool: ThreadPool = ThreadPool::new(1);
let first_res: SendResult = thread_pool.execute(|| {
println!("first");
});
println!("{:?}", first_res);
let panic_res: SendResult = thread_pool.execute_with_catch(
|| {
panic!("[panic]");
},
|err| {
println!("Catch panic {}", err);
},
);
println!("{:?}", panic_res);
let second_res: SendResult = thread_pool.execute_with_catch_finally(
|| {
panic!("[panic]");
},
|_err| {
panic!("[panic]");
},
|| {
println!("finally");
},
);
println!("{:?}", second_res);
sleep(Duration::from_secs(10));
use recoverable_thread_pool::*;
use std::{thread::sleep, time::Duration};
let thread_pool: ThreadPool = ThreadPool::new(1);
let first_res: SendResult = thread_pool.async_execute(|| async {
println!("first");
});
println!("{:?}", first_res);
let panic_res: SendResult = thread_pool.async_execute_with_catch(
|| async {
panic!("[panic]");
},
|err| async move {
println!("Catch panic {}", err);
},
);
println!("{:?}", panic_res);
let second_res: SendResult = thread_pool.async_execute_with_catch_finally(
|| async {
panic!("[panic]");
},
|_err| async {
panic!("[panic]");
},
|| async {
println!("finally");
},
);
println!("{:?}", second_res);
sleep(Duration::from_secs(10));
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 root@ltpp.vip.