Skip to content

Commit

Permalink
refresh the component immediately after create it
Browse files Browse the repository at this point in the history
  • Loading branch information
sangluo committed Aug 21, 2022
1 parent 044871f commit c69275d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions examples/temperature.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use sysinfo::SystemExt;

fn main() {
let mut sys = sysinfo::System::new();

sys.refresh_components_list();

for _ in 0..9999 {
sys.refresh_components();
for m in sys.components() {
println!("{:?}", m);
}
std::thread::sleep(std::time::Duration::from_millis(500));
}
}
6 changes: 4 additions & 2 deletions src/apple/macos/component/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ impl Components {
CFStringGetCStringPtr(name.inner() as *const _, kCFStringEncodingUTF8);
let name_str = CStr::from_ptr(name_ptr).to_string_lossy().to_string();

self.inner
.push(Component::new(name_str, None, None, service));
let mut component = Component::new(name_str, None, None, service);
component.refresh();

self.inner.push(component);
}

self.client.replace(client);
Expand Down

0 comments on commit c69275d

Please sign in to comment.