-
Notifications
You must be signed in to change notification settings - Fork 42
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
implement TcpStream::peek methods #64
Conversation
refactor `StreamSocket` by replacing the channel with a buffer of segments, along with a slot for a waker. `StreamSocket` exposes 2 methods: `poll_read_ready` and `try_read` mimicking tokio in both API and behavior.
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.
Overall LGTM just two questions
} | ||
|
||
impl ReadHalf { | ||
fn poll_read_priv(&mut self, cx: &mut Context<'_>, buf: &mut ReadBuf) -> Poll<Result<()>> { | ||
if self.is_closed || buf.capacity() == 0 { | ||
if buf.capacity() == 0 { |
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.
Why remove this check for 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.
see #63 (comment)
match host.tcp.socket_mut(&self.pair) { | ||
Some(socket) => { | ||
ready!(socket.poll_read_ready(cx)); | ||
unsafe { |
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.
I wonder if it makes sense to break up the unsafe blocks to only the unsafe components instead of wrapping it all in one block. That said, I don't remember how we do it in tokio so this could be fine.
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.
from the snippets I see in tokio, unsafe blocks seem to often contain whole blocks rather than single statements
Closing due to no activity. |
This PR implements the
TcpStream
peek
andpoll_peek
methods.depends on #63