From fb55ce91900aed869e85968e8c7bc8c75f95f891 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 10 Sep 2024 19:10:16 +0500 Subject: [PATCH] wip --- ntex-glommio/src/io.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ntex-glommio/src/io.rs b/ntex-glommio/src/io.rs index 53166de7..b6b67a7a 100644 --- a/ntex-glommio/src/io.rs +++ b/ntex-glommio/src/io.rs @@ -1,11 +1,9 @@ -use std::task::{Context, Poll}; -use std::{any, future::poll_fn, future::Future, io, pin::Pin}; +use std::{any, future::poll_fn, io, pin::Pin, task::ready, task::Context, task::Poll}; -use futures_lite::future::FutureExt; use futures_lite::io::{AsyncRead, AsyncWrite}; use ntex_bytes::{Buf, BufMut, BytesVec}; -use ntex_io::{types, Handle, IoStream, ReadContext, WriteContext, WriteStatus}; -use ntex_util::{ready, time::sleep, time::Sleep}; +use ntex_io::{types, Handle, IoStream, ReadContext, WriteContext}; +use ntex_util::future::lazy; use crate::net_impl::{TcpStream, UnixStream}; @@ -63,7 +61,7 @@ struct Write(TcpStream); impl ntex_io::AsyncWrite for Write { #[inline] async fn write(&mut self, mut buf: BytesVec) -> (BytesVec, io::Result<()>) { - match lazy(|cx| flush_io(&mut *self.0.borrow_mut(), &mut buf, cx)).await { + match lazy(|cx| flush_io(&mut self.0, &mut buf, cx)).await { Poll::Ready(res) => (buf, res), Poll::Pending => (buf, Ok(())), } @@ -76,7 +74,7 @@ impl ntex_io::AsyncWrite for Write { #[inline] async fn shutdown(&mut self) -> io::Result<()> { - poll_fn(|cx| Pin::new(&mut *self.0.borrow_mut()).poll_close(cx)).await + poll_fn(|cx| Pin::new(&mut self.0).poll_close(cx)).await } } @@ -178,7 +176,7 @@ struct UnixWrite(UnixStream); impl ntex_io::AsyncWrite for UnixWrite { #[inline] async fn write(&mut self, mut buf: BytesVec) -> (BytesVec, io::Result<()>) { - match lazy(|cx| flush_io(&mut *self.0.borrow_mut(), &mut buf, cx)).await { + match lazy(|cx| flush_io(&mut self.0, &mut buf, cx)).await { Poll::Ready(res) => (buf, res), Poll::Pending => (buf, Ok(())), } @@ -191,6 +189,6 @@ impl ntex_io::AsyncWrite for UnixWrite { #[inline] async fn shutdown(&mut self) -> io::Result<()> { - poll_fn(|cx| Pin::new(&mut *self.0.borrow_mut()).poll_close(cx)).await + poll_fn(|cx| Pin::new(&mut self.0).poll_close(cx)).await } }