Skip to content

Commit b0b4cff

Browse files
author
Stjepan Glavina
committed
Restrict yielding to reads
1 parent 3780702 commit b0b4cff

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ impl<T> Async<T> {
647647
pub async fn write_with<R>(&self, op: impl FnMut(&T) -> io::Result<R>) -> io::Result<R> {
648648
let mut op = op;
649649
loop {
650-
future::poll_fn(|cx| maybe_yield(cx)).await;
651650
match op(self.get_ref()) {
652651
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
653652
res => return res,
@@ -685,7 +684,6 @@ impl<T> Async<T> {
685684
) -> io::Result<R> {
686685
let mut op = op;
687686
loop {
688-
future::poll_fn(|cx| maybe_yield(cx)).await;
689687
match op(self.get_mut()) {
690688
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
691689
res => return res,
@@ -776,7 +774,6 @@ impl<T: Write> AsyncWrite for Async<T> {
776774
cx: &mut Context<'_>,
777775
buf: &[u8],
778776
) -> Poll<io::Result<usize>> {
779-
ready!(maybe_yield(cx));
780777
match (&mut *self).get_mut().write(buf) {
781778
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
782779
res => return Poll::Ready(res),
@@ -790,7 +787,6 @@ impl<T: Write> AsyncWrite for Async<T> {
790787
cx: &mut Context<'_>,
791788
bufs: &[IoSlice<'_>],
792789
) -> Poll<io::Result<usize>> {
793-
ready!(maybe_yield(cx));
794790
match (&mut *self).get_mut().write_vectored(bufs) {
795791
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
796792
res => return Poll::Ready(res),
@@ -800,7 +796,6 @@ impl<T: Write> AsyncWrite for Async<T> {
800796
}
801797

802798
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
803-
ready!(maybe_yield(cx));
804799
match (&mut *self).get_mut().flush() {
805800
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
806801
res => return Poll::Ready(res),
@@ -823,7 +818,6 @@ where
823818
cx: &mut Context<'_>,
824819
buf: &[u8],
825820
) -> Poll<io::Result<usize>> {
826-
ready!(maybe_yield(cx));
827821
match (&*self).get_ref().write(buf) {
828822
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
829823
res => return Poll::Ready(res),
@@ -837,7 +831,6 @@ where
837831
cx: &mut Context<'_>,
838832
bufs: &[IoSlice<'_>],
839833
) -> Poll<io::Result<usize>> {
840-
ready!(maybe_yield(cx));
841834
match (&*self).get_ref().write_vectored(bufs) {
842835
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
843836
res => return Poll::Ready(res),
@@ -847,7 +840,6 @@ where
847840
}
848841

849842
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
850-
ready!(maybe_yield(cx));
851843
match (&*self).get_ref().flush() {
852844
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {}
853845
res => return Poll::Ready(res),

0 commit comments

Comments
 (0)