Hi there.
For this code:
fn main() {
loop {
}
}
Activity Monitor.app
shows the following usage percentage:
The reason I'm looking into this is because Gilrs (an rs
gamepad input library) shows their getting started example using that same structure:
When using this loop{}
construct and running my own program, I notice my laptop fans kicking into high gear. So, I'm wondering if there is a better way to consume the Gilrs events?
I don't have this type of issue when writing Node, or at least I've never had to use a loop{}
construct to passively consume events, so I'm guessing I just have some kind of fundamental misunderstanding for Rust. My intuition is that such a simple program doesn't need to be the most CPU hungry thing on the machine, and I that I need to rate limit the loop in some way (as silly as that sounds).
I tried to search for similar topics about 100% CPU usage, but didn't find an answer; probably because this is a really basic question, and I'm just ignorant / missing something obvious?
If someone can help lift my ignorance here I would appreciate the help. I have a feeling the answer is going to be obvious but for whatever reason I can't think what to try next.
Thanks!