-
Notifications
You must be signed in to change notification settings - Fork 28
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
make initial poll loop less aggressive #15
Conversation
The async fn didn’t actually yield; it does now. Also report socket closure as an error.
Can you expand on this @rkuhn? |
Previously, this was just a loop, calling poll back-to-back with no pause. An |
I am still confused. The |
No, |
That would be surprising to me. If you use the the Tools->Expand-macros feature of the testground below you see a sample |
Sorry, you’re right — today was quite tough and I mixed up macro definitions. I still find my version easier to read; semantics of polling and wakers is sufficiently brittle in Rust async that every layer of abstraction on top of it is more risk than gain. |
Agreed. I will take a closer look next week. Currently on vacation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. @dvc94ch any comments from your end?
Ok(None) => break, | ||
Err(err) => return Err(Error::new(ErrorKind::Other, err)), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this should be equivalent. is it really easier to read? in the special case that you only need to poll two futures, maybe, maybe not. for polling more futures/streams select!
macro is the way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust async poses an interesting challenge for developers due to the interactions with other language features. Having all .await
points exposed and clearly visible in an async
scope is the only way to make that manageable — a macro that expands to .await
within the current async
scope is actively harmful. Imagine having to debug compiler error messages that some faraway type is not Sync?
ErrorKind::BrokenPipe, | ||
"rtnetlink socket closed", | ||
))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change looks fine to me
The async fn didn’t actually yield; it does now.
Also report socket closure as an error.