#day #format #hyperlane #networking #language #time

recoverable-spawn

A thread 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.

29 releases (17 stable)

Uses new Rust 2024

new 3.5.1 Mar 23, 2025
3.4.1 Feb 9, 2025
2.0.0 Jan 11, 2025
1.0.0 Jan 10, 2025
0.8.0 Jan 10, 2025

#1304 in Network programming

Download history 579/week @ 2025-01-04 817/week @ 2025-01-11 728/week @ 2025-01-18 22/week @ 2025-01-25 90/week @ 2025-02-01 295/week @ 2025-02-08 243/week @ 2025-02-15 139/week @ 2025-02-22 396/week @ 2025-03-01 319/week @ 2025-03-08 459/week @ 2025-03-15

1,339 downloads per month
Used in 7 crates (5 directly)

MIT license

33KB
374 lines

recoverable-spawn

Official Documentation

Api Docs

A thread 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-spawn

Use

recoverable_spawn

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();

recoverable_spawn_with_error_handle

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();

async_recoverable_spawn

use recoverable_spawn::*;
let msg: &str = "test";
let handle: JoinHandle<()> = async_recoverable_spawn(move || async move {
    panic!("{}", msg);
});
let _ = handle.join();

async_recoverable_spawn_catch

use recoverable_spawn::*;
let msg: &str = "test";
let handle: JoinHandle<()> = async_recoverable_spawn_catch(
    move || async move {
        panic!("{}", msg);
    },
    move |err| async move {
        println!("handle error => {}", err);
    },
);
let _ = handle.join();

async_recoverable_spawn_catch_finally

use recoverable_spawn::*;
let msg: &str = "test";
let handle: JoinHandle<()> = async_recoverable_spawn_catch_finally(
    move || async move {
        panic!("{}", msg);
    },
    move |err| async move {
        println!("handle error => {}", err);
        panic!("{}", err);
    },
    move || async move {
        println!("finally");
    },
);
let _ = handle.join();

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

~2.4–8MB
~58K SLoC