A threadpool.
You can use it alone or with safina
,
a safe async runtime.
FnOnce
to the poolforbid(unsafe_code)
std
https://docs.rs/safina-threadpool
rust
let pool =
safina_threadpool::ThreadPool::new("worker", 2).unwrap();
let receiver = {
let (sender, receiver) =
std::sync::mpsc::channel();
for data in data_source {
let sender_clone = sender.clone();
pool.schedule(
move || process_data(data, sender_clone));
}
receiver
};
let results: Vec<ProcessResult> =
receiver.iter().collect();
// ...
blocking
unsafe
codethreadpool
unsafe
codefutures-executor
unsafe
scoped_threadpool
unsafe
codescheduled-thread-pool
unsafe
codeworkerpool
unsafe
codethreads_pool
unsafe
thread-pool
unsafe
codetasque
unsafe
codefast-threadpool
unsafe
codeblocking-permit
unsafe
rayon-core
unsafe
ThreadPool::join
and ThreadPool::try_join
.ThreadPool::new
to return Result
.ThreadPool::try_schedule
to return an error when it fails to restart panicked threads.ThreadPool::schedule
to handle failure starting replacement threads.respawn_threads
function.Cargo.toml
and bump version number../release.sh
License: Apache-2.0