Coder Social home page Coder Social logo

core_affinity_rs's Introduction

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 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, 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

core_affinity_rs's People

Contributors

elzair avatar mottl avatar grembo avatar nau avatar chiplis avatar nviennot avatar stlankes avatar figsoda avatar s1341 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.