6 releases

Uses old Rust 2015

0.5.10 Dec 20, 2019
0.5.9 Oct 10, 2017
0.5.8 Sep 29, 2017
0.4.2 Sep 15, 2017

#65 in Operating systems

Download history 974/week @ 2021-01-12 1134/week @ 2021-01-19 1025/week @ 2021-01-26 1210/week @ 2021-02-02 1066/week @ 2021-02-09 1266/week @ 2021-02-16 1243/week @ 2021-02-23 1111/week @ 2021-03-02 1359/week @ 2021-03-09 1953/week @ 2021-03-16 2210/week @ 2021-03-23 1692/week @ 2021-03-30 1544/week @ 2021-04-06 1455/week @ 2021-04-13 2428/week @ 2021-04-20 1981/week @ 2021-04-27

4,309 downloads per month
Used in 34 crates (25 directly)

MIT/Apache

15KB
308 lines

core_affinity_rs is a Rust crate for managing CPU affinities. It currently supports Linux, Mac OSX, and Windows.

Documentation

Linux Status Build status

Example

This example shows how create a thread for each available processor and pin each thread to its corresponding processor.

extern crate core_affinity;

use std::thread;

// Retrieve the IDs of all active CPU cores.
let core_ids = core_affinity::get_core_ids().unwrap();

// Create a thread for each active CPU core.
let handles = core_ids.into_iter().map(|id| {
    thread::spawn(move || {
        // Pin this thread to a single CPU core.
        core_affinity::set_for_current(id);
        // Do more work after this.
    })
}).collect::<Vec<_>>();

for handle in handles.into_iter() {
    handle.join().unwrap();
}

Platforms

core_affinity_rs should work on Linux, Windows, Mac OSX, and Android.

core_affinity_rs is continuously tested on:

  • x86_64-unknown-linux-gnu (Linux)
  • i686-unknown-linux-gnu
  • x86_64-unknown-linux-musl (Linux w/ MUSL)
  • i686-unknown-linux-musl
  • x86_64-apple-darwin (Mac OSX)
  • i686-apple-darwin
  • x86_64-pc-windows-msvc (Windows)
  • i686-pc-windows-msvc
  • x86_64-pc-windows-gnu
  • i686-pc-windows-gnu

core_affinity_rs is continuously cross-compiled for:

  • arm-unknown-linux-gnueabihf
  • aarch64-unknown-linux-gnu
  • mips-unknown-linux-gnu
  • aarch64-unknown-linux-musl
  • i686-linux-android
  • x86_64-linux-android
  • arm-linux-androideabi
  • aarch64-linux-android

Dependencies

~67KB