Expand description
§windows-threading
The windows-threading crate wraps the Windows thread pool.
Start by adding the following to your Cargo.toml file:
[dependencies.windows-threading]
version = "0.100"Submit work to the default pool:
windows_threading::submit(|| {
println!("thread: {}", windows_threading::thread_id());
loop {
println!(".");
windows_threading::sleep(1000);
}
});Process an iterator in parallel:
let counter = std::sync::RwLock::<usize>::new(0);
windows_threading::for_each(0..10, |value| {
println!("thread: {}, value: {value}", windows_threading::thread_id());
let mut counter = counter.write().unwrap();
*counter += value;
});
assert_eq!(*counter.read().unwrap(), 45);Structs§
- Pool
- A
Poolobject represents a private thread pool with its own thread limits. - Scope
- A scope to submit closures in.