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

event_loop: correctly use prepare_read() #214

Merged
merged 1 commit into from
Dec 27, 2021
Merged

Conversation

elinorbgr
Copy link
Member

Fixes #212

@Molytho can you confirm this one is correct for good?

@Molytho
Copy link

Molytho commented Dec 27, 2021

It works perfectly fine 👍.

One last thing:
Maybe replace this

loop {
let ret = callback((), queue);
match ret {
Ok(0) => {
// no events were dispatched even after reading the socket,
// nothing more to do, stop here
*read_guard = queue.prepare_read();
break;
}
Ok(_) => {
*read_guard = queue.prepare_read();
continue;
}
Err(e) => {
// in case of error, forward it and fast-exit
return Err(e);
}
}
}

with that
loop {
match self.queue.prepare_read() {
Some(guard) => {
self.read_guard = Some(guard);
break;
}
None => {
callback((), &mut self.queue)?;
}
}
}

because prepare_read is no longer needed in the Ok(_) => { ... } path and because prepare_read can fail in the Ok(0) => { ... } when something is read in between of callback and prepare_read (I know that's very unlikely to ever happen but when it happens once it's impossible to track down)

@elinorbgr
Copy link
Member Author

Ah yes, good point!

@Molytho
Copy link

Molytho commented Dec 27, 2021

It works. I think it's ready to be commited

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

Successfully merging this pull request may close these issues.

Huge slowdowns with wayland on nvidia gpus
2 participants