Crates.io | affinity |
lib.rs | affinity |
version | 0.1.2 |
source | src |
created_at | 2020-04-03 15:59:20.183981 |
updated_at | 2021-10-16 16:11:36.166096 |
description | Provides a consistent way to set core affinity for currently running threads and processes |
homepage | |
repository | https://github.com/elast0ny/affinity-rs |
max_upload_size | |
id | 225964 |
size | 17,631 |
This crate provides a consistent way to set core affinity for currently running threads and processes.
use affinity::*;
fn bind_even_cores() {
// Select every second core
let cores: Vec<usize> = (0..get_core_num()).step_by(2).collect();
println!("Binding thread to cores : {:?}", &cores);
// Output : "Binding thread to cores : [0, 2, 4, 6]"
set_thread_affinity(&cores).unwrap();
println!("Current thread affinity : {:?}", get_thread_affinity().unwrap());
// Output : "Current thread affinity : [0, 2, 4, 6]"
}
Complete example here.
set_process_affinity()
)Currently only tested on :
Windows
Linux (Arch x64)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.