| Crates.io | safina-threadpool |
| lib.rs | safina-threadpool |
| version | 0.2.5 |
| created_at | 2020-12-19 05:09:33.296949+00 |
| updated_at | 2024-10-27 23:34:59.537182+00 |
| description | Safe thread pool - ARCHIVED: Code moved to `safina` crate. |
| homepage | |
| repository | https://gitlab.com/leonhard-llc/safina-rs |
| max_upload_size | |
| id | 324518 |
| size | 44,059 |
This crate is archived and will not be updated.
The code is now at
safina::threadpool in the
safina crate.
A threadpool.
You can use it alone or with safina,
a safe async runtime.
FnOnce to the pool and one of the threads will execute itThreadPool struct to stop all idle threads.forbid(unsafe_code)stdlet 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 codescoped_threadpool
unsafe codescheduled-thread-pool
unsafe codeworkerpool
unsafe codethreads_pool
unsafethread-pool
unsafe codetasque
unsafe codefast-threadpool
unsafe codeblocking-permit
unsaferayon-core
unsafeFrom<NewThreadPoolError> and From<TryScheduleError> for std::io::Error.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.join and try_join work with Arc<ThreadPool>.respawn_threads function.