This commit is contained in:
2026-03-02 05:37:56 +00:00
parent 235d31e263
commit 1a8da28cfc
4 changed files with 124 additions and 1 deletions

44
src/cpu.rs Normal file
View File

@@ -0,0 +1,44 @@
use std::{
collections::HashMap,
string,
sync::{Arc, Mutex},
};
use core_affinity::*;
use std::thread;
pub struct Cpu {
pub cores: HashMap<i32, CpuCore>,
}
struct CpuCore {}
enum CoreType {
P, // Performence
E, // Efficent
L, // Low power
}
impl Cpu {
pub fn new() -> Cpu {
let cpu = Arc::new(Mutex::new(Cpu {
cores: HashMap::new(),
}));
let _ = 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 {
return;
}
})
})
.collect::<Vec<_>>();
for handle in handles.into_iter() {
handle.join().unwrap();
}
}
}

View File

@@ -1,4 +1,8 @@
use raw_cpuid::*;
mod cpu;
fn main() {
let a = cpuid!(26, 0);
println!("{:?}", a);
println!("Hello, world!");
meow
}