9 releases (4 stable)
new 1.1.1 | Jan 13, 2025 |
---|---|
1.0.1 | Jan 11, 2025 |
0.3.0 | Jan 11, 2025 |
0.1.0 | Jan 10, 2025 |
0.0.3 | Jan 10, 2025 |
#1036 in Network programming
715 downloads per month
Used in 2 crates
9KB
142 lines
recoverable-thread-pool
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.
Installation
To use this crate, you can run cmd:
cargo add recoverable-thread-pool
Use
use recoverable_thread_pool::*;
let thread_pool: ThreadPool = ThreadPool::new(1);
let first_res: SendResult = thread_pool.execute(
|| {
println!("first");
},
|_err| {},
|| {
println!("finally");
},
);
println!("{:?}", first_res);
let panic_res: SendResult = thread_pool.execute(
|| {
panic!("[panic]");
},
|err| {
println!("Catch panic {}", err);
panic!("[panic]");
},
|| {
println!("finally");
},
);
println!("{:?}", panic_res);
let second_res: SendResult = thread_pool.execute(
|| {
panic!("[panic]");
},
|_err| {
panic!("[panic]");
},
|| {
println!("finally");
},
);
println!("{:?}", second_res);
loop {}
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Contact
For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.
Dependencies
~255–710KB
~17K SLoC