a
This commit is contained in:
44
src/cpu.rs
Normal file
44
src/cpu.rs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
use raw_cpuid::*;
|
||||
mod cpu;
|
||||
|
||||
fn main() {
|
||||
let a = cpuid!(26, 0);
|
||||
println!("{:?}", a);
|
||||
println!("Hello, world!");
|
||||
meow
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user