Skip to content

Commit

Permalink
src: {apple,freebsd,unknown,windows}: Add governor function for Syste…
Browse files Browse the repository at this point in the history
…mExt

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Sep 3, 2023
1 parent 337c0cf commit 3231833
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/apple/cpu.rs
@@ -1,7 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::sys::utils::{get_sys_value, get_sys_value_by_name};
use crate::{CpuExt, CpuRefreshKind};
use crate::{CpuExt, CpuRefreshKind, GovernorKind};

use libc::{c_char, c_void, host_processor_info, mach_port_t, mach_task_self};
use std::mem;
Expand Down Expand Up @@ -170,6 +170,10 @@ impl CpuExt for Cpu {
fn brand(&self) -> &str {
&self.brand
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}
}

pub(crate) unsafe fn get_cpu_frequency() -> u64 {
Expand Down
7 changes: 6 additions & 1 deletion src/apple/system.rs
Expand Up @@ -6,7 +6,8 @@ use crate::sys::process::*;
use crate::sys::utils::{get_sys_value, get_sys_value_by_name};

use crate::{
CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, SystemExt, User,
CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind,
SystemExt, User,
};

#[cfg(all(target_os = "macos", not(feature = "apple-sandbox")))]
Expand Down Expand Up @@ -346,6 +347,10 @@ impl SystemExt for System {
&self.cpus.global_cpu
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}

fn cpus(&self) -> &[Cpu] {
&self.cpus.cpus
}
Expand Down
6 changes: 5 additions & 1 deletion src/freebsd/cpu.rs
Expand Up @@ -3,7 +3,7 @@
use crate::sys::utils::{
get_sys_value_array, get_sys_value_by_name, get_sys_value_str_by_name, init_mib, VecSwitcher,
};
use crate::{CpuExt, CpuRefreshKind};
use crate::{CpuExt, CpuRefreshKind, GovernorKind};

use libc::{c_int, c_ulong};

Expand Down Expand Up @@ -171,6 +171,10 @@ impl CpuExt for Cpu {
fn brand(&self) -> &str {
""
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}
}

pub(crate) fn physical_core_count() -> Option<usize> {
Expand Down
8 changes: 6 additions & 2 deletions src/freebsd/system.rs
Expand Up @@ -2,8 +2,8 @@

use crate::{
sys::{component::Component, Cpu, Process},
CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, SystemExt,
User,
CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind,
SystemExt, User,
};

use std::cell::UnsafeCell;
Expand Down Expand Up @@ -210,6 +210,10 @@ impl SystemExt for System {
&self.cpus.global_cpu
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}

fn cpus(&self) -> &[Cpu] {
&self.cpus.cpus
}
Expand Down
6 changes: 5 additions & 1 deletion src/unknown/cpu.rs
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::CpuExt;
use crate::{CpuExt, GovernorKind};

#[doc = include_str!("../../md_doc/cpu.md")]
pub struct Cpu {}
Expand Down Expand Up @@ -31,4 +31,8 @@ impl CpuExt for Cpu {
fn brand(&self) -> &str {
""
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}
}
8 changes: 6 additions & 2 deletions src/unknown/system.rs
Expand Up @@ -2,8 +2,8 @@

use crate::{
sys::{component::Component, Cpu, Process},
CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, SystemExt,
User,
CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind,
SystemExt, User,
};

use std::collections::HashMap;
Expand Down Expand Up @@ -74,6 +74,10 @@ impl SystemExt for System {
&self.global_cpu
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}

fn cpus(&self) -> &[Cpu] {
&[]
}
Expand Down
6 changes: 5 additions & 1 deletion src/windows/cpu.rs
@@ -1,7 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::sys::tools::KeyHandler;
use crate::{CpuExt, CpuRefreshKind, LoadAvg};
use crate::{CpuExt, CpuRefreshKind, GovernorKind, LoadAvg};

use std::collections::HashMap;
use std::io::Error;
Expand Down Expand Up @@ -332,6 +332,10 @@ impl CpuExt for Cpu {
fn brand(&self) -> &str {
&self.brand
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}
}

impl Cpu {
Expand Down
8 changes: 6 additions & 2 deletions src/windows/system.rs
@@ -1,8 +1,8 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{
CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessExt, ProcessRefreshKind, RefreshKind,
SystemExt, User,
CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessExt, ProcessRefreshKind,
RefreshKind, SystemExt, User,
};
use winapi::um::winreg::HKEY_LOCAL_MACHINE;

Expand Down Expand Up @@ -369,6 +369,10 @@ impl SystemExt for System {
self.cpus.global_cpu()
}

fn governor(&self) -> GovernorKind {
GovernorKind::default()
}

fn cpus(&self) -> &[Cpu] {
self.cpus.cpus()
}
Expand Down

0 comments on commit 3231833

Please sign in to comment.