MCPcopy Index your code
hub / github.com/Elzair/core_affinity_rs

github.com/Elzair/core_affinity_rs @0.8.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.8.3 ↗ · + Follow
23 symbols 76 edges 1 files 2 documented · 9%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

Documentation

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 cores on which the current
// thread is allowed to run.
// NOTE: If you want ALL the possible cores, you should
// use num_cpus.
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.
        let res = core_affinity::set_for_current(id);
        if (res) {
          // 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, FreeBSD, NetBSD, and Android.

Core symbols most depended-on inside this repo

get_core_ids
called by 17
src/lib.rs
get_affinity_mask
called by 10
src/lib.rs
set_for_current
called by 8
src/lib.rs
new_cpu_set
called by 6
src/lib.rs
get_core_ids_helper
called by 1
src/lib.rs
set_for_current_helper
called by 1
src/lib.rs

Shape

Function 21
Class 2

Languages

Rust100%

Modules by API surface

src/lib.rs23 symbols

For agents

$ claude mcp add core_affinity_rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact