Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need to poll every 500ms if state is not dirty #6

Open
lutzky opened this issue Aug 23, 2024 · 0 comments
Open

No need to poll every 500ms if state is not dirty #6

lutzky opened this issue Aug 23, 2024 · 0 comments

Comments

@lutzky
Copy link
Owner

lutzky commented Aug 23, 2024

When handling events, we poll every 500ms:

zsnapfree/src/app.rs

Lines 165 to 177 in 60e6c61

fn handle_events(&mut self) -> Result<()> {
if poll(Duration::from_millis(500))? {
match event::read()? {
Event::Key(key_event) if key_event.kind == KeyEventKind::Press => {
self.handle_key_event(key_event);
}
_ => {}
};
} else {
self.recalculate_result();
}
Ok(())
}

However, if self.dirty is false, we can poll indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant