Crates.io | poolparty |
lib.rs | poolparty |
version | 2.0.1 |
source | src |
created_at | 2020-02-26 07:45:47.073912 |
updated_at | 2021-10-13 12:35:08.349713 |
description | Added functionality for the `futures::executor::ThreadPool` futures executor. |
homepage | |
repository | https://github.com/xermicus/poolparty |
max_upload_size | |
id | 212657 |
size | 23,395 |
Tiny crate providing added functionality to the futures-rs threadpool executor.
The futures::future::ThreadPool
executor currently has no way built in to handle panics, manually stop the pool execution or bubble up errors back to the caller.
The crate works around these limitations (it might get obsolete once this open issue will be resolved).
Use cases for the crate are:
⚠ This crate is beeing passively maintained. It works just fine for me in an existing project. However I'll be using smol as my futures executor in new projects. The smol
task handles offer the same functionality (and more), rendering this crate obsolete.
The following example demonstrates the handling of a failing task:
async fn forever() -> Result<(),String> {
loop {}
}
async fn fail(msg: String) -> Result<(),String> {
Err(msg)
}
let mut pool = StoppableThreadPool::new()?;
let err = "fail_function_called".to_string();
pool.spawn(fail(err.clone()));
pool.spawn(forever());
assert_eq!(
pool.observe().await.unwrap_err(),
err
)
Have a look at the tests in lib.rs for more usage examples.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in poolparty by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.