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

Impl poll_readable and poll_writable. #37

Closed
wants to merge 1 commit into from

Commits on Oct 8, 2020

  1. Impl poll_readable and poll_writable.

    ```rust
    pub struct ListenStream {
        listener: Async<TcpListener>,
    }
    
    impl Stream for ListenStream {
        type Item = Result<Async<TcpStream>, std::io::Error>;
    
        fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
            loop {
                match self.listener.accept().now_or_never() {
                    Some(Ok((stream, _))) => {
                        return Poll::Ready(Some(Ok(stream)));
                    }
                    Some(Err(err)) => {
                        return Poll::Ready(Some(Err(err)));
                    }
                    None => {
                        match self.listener.poll_readable(cx) {
                            Poll::Ready(Ok(())) => continue,
                            Poll::Pending => return Poll::Pending,
                            Poll::Ready(Err(err)) => return Poll::Ready(Some(Err(err))),
                        }
                    }
                }
            }
        }
    }
    ```
    dvc94ch committed Oct 8, 2020
    Configuration menu
    Copy the full SHA
    ca54598 View commit details
    Browse the repository at this point in the history