From 240769c1b7663abd47ce0881736d3575028399b8 Mon Sep 17 00:00:00 2001 From: ben1009 Date: Fri, 21 Jul 2023 12:09:52 +0800 Subject: [PATCH] fix: fix typos --- .vscode/settings.json | 5 +++++ examples/timer_select.rs | 2 +- monoio-compat/src/tcp_unsafe.rs | 2 +- monoio/Cargo.toml | 2 +- monoio/src/blocking.rs | 4 ++-- monoio/src/driver/op/accept.rs | 2 +- monoio/src/io/util/cancel.rs | 10 +++++----- monoio/src/io/util/copy.rs | 12 ++++++------ monoio/src/net/mod.rs | 2 +- monoio/src/net/tcp/listener.rs | 2 +- monoio/src/net/tcp/stream.rs | 8 ++++---- monoio/src/net/udp.rs | 8 ++++---- monoio/src/net/unix/listener.rs | 2 +- monoio/src/net/unix/seq_packet/listener.rs | 2 +- monoio/src/net/unix/stream.rs | 8 ++++---- monoio/src/utils/slab.rs | 2 +- 16 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..ac64936d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "rust-analyzer.linkedProjects": [ + "./monoio/Cargo.toml" + ] +} \ No newline at end of file diff --git a/examples/timer_select.rs b/examples/timer_select.rs index f3c83880..47afd029 100644 --- a/examples/timer_select.rs +++ b/examples/timer_select.rs @@ -27,7 +27,7 @@ async fn main() { } } - // A very improtant thing is if you use select to do timeout io, + // A very important thing is if you use select to do timeout io, // you must cancel it manually. // In epoll, dropping a read future has no side effect since we // only wait for io ready, after waiting aborted, no syscall diff --git a/monoio-compat/src/tcp_unsafe.rs b/monoio-compat/src/tcp_unsafe.rs index 30dfca8a..15f6dae7 100644 --- a/monoio-compat/src/tcp_unsafe.rs +++ b/monoio-compat/src/tcp_unsafe.rs @@ -54,7 +54,7 @@ impl TcpStreamCompat { /// /// # Safety /// User must ensure that the data slice pointer and length is always - /// valid and the same among diffrent calls before Poll::Ready returns. + /// valid and the same among different calls before Poll::Ready returns. pub unsafe fn new(stream: TcpStream) -> Self { Self { stream, diff --git a/monoio/Cargo.toml b/monoio/Cargo.toml index 37c0d8fc..b954f07e 100644 --- a/monoio/Cargo.toml +++ b/monoio/Cargo.toml @@ -71,7 +71,7 @@ debug = ["tracing"] legacy = ["mio"] # iouring support iouring = [] -# tokio-compatiable(only have effect when legacy is enabled and iouring is not) +# tokio-compatible(only have effect when legacy is enabled and iouring is not) tokio-compat = ["tokio"] # signal enables setting ctrl_c handler signal = ["ctrlc", "sync"] diff --git a/monoio/src/blocking.rs b/monoio/src/blocking.rs index ecfaedf7..7d3469d7 100644 --- a/monoio/src/blocking.rs +++ b/monoio/src/blocking.rs @@ -25,7 +25,7 @@ pub enum JoinError { } /// BlockingTask is contrusted by monoio, ThreadPool impl -/// will exeucte it with `.run()`. +/// will execute it with `.run()`. pub struct BlockingTask { task: Option>, blocking_vtable: &'static BlockingTaskVtable, @@ -118,7 +118,7 @@ where join } -/// DefaultThreadPool is a simple wrapped `threadpool::ThreadPool` that implememt +/// DefaultThreadPool is a simple wrapped `threadpool::ThreadPool` that implement /// `monoio::blocking::ThreadPool`. You may use this implementation, or you can use your own thread /// pool implementation. #[derive(Clone)] diff --git a/monoio/src/driver/op/accept.rs b/monoio/src/driver/op/accept.rs index 090d73bb..4e708e49 100644 --- a/monoio/src/driver/op/accept.rs +++ b/monoio/src/driver/op/accept.rs @@ -81,7 +81,7 @@ impl OpAble for Accept { let fd = self.fd.as_raw_fd(); let addr = self.addr.0.as_mut_ptr() as *mut _; let len = &mut self.addr.1; - // Here I use copied some code from mio because I don't want the convertion. + // Here I use copied some code from mio because I don't want the conversion. // On platforms that support it we can use `accept4(2)` to set `NONBLOCK` // and `CLOEXEC` in the call to accept the connection. diff --git a/monoio/src/io/util/cancel.rs b/monoio/src/io/util/cancel.rs index f7d57b60..fdc56e32 100644 --- a/monoio/src/io/util/cancel.rs +++ b/monoio/src/io/util/cancel.rs @@ -10,13 +10,13 @@ pub struct CancelHandle { } /// Canceller is a user-hold struct to cancel io operations. -/// A canceller can assocate with multiple io operations. +/// A canceller can associate with multiple io operations. #[derive(Default)] pub struct Canceller { shared: Rc>, } -pub(crate) struct AssocateGuard { +pub(crate) struct AssociateGuard { op_canceller: OpCanceller, shared: Rc>, } @@ -67,19 +67,19 @@ impl CancelHandle { self.shared.borrow().canceled } - pub(crate) fn assocate_op(self, op_canceller: OpCanceller) -> AssocateGuard { + pub(crate) fn associate_op(self, op_canceller: OpCanceller) -> AssociateGuard { { let mut shared = self.shared.borrow_mut(); shared.slot_ref.insert(op_canceller.clone()); } - AssocateGuard { + AssociateGuard { op_canceller, shared: self.shared, } } } -impl Drop for AssocateGuard { +impl Drop for AssociateGuard { fn drop(&mut self) { let mut shared = self.shared.borrow_mut(); shared.slot_ref.remove(&self.op_canceller); diff --git a/monoio/src/io/util/copy.rs b/monoio/src/io/util/copy.rs index 23111ecb..bd351ea0 100644 --- a/monoio/src/io/util/copy.rs +++ b/monoio/src/io/util/copy.rs @@ -16,7 +16,7 @@ where W: AsyncWriteRent + ?Sized, { let mut buf: Vec = Vec::with_capacity(BUF_SIZE); - let mut transfered: u64 = 0; + let mut transferred: u64 = 0; 'r: loop { let (read_res, mut buf_read) = reader.read(buf).await; @@ -60,7 +60,7 @@ where } Ok(n) => { // go read data - transfered += n as u64; + transferred += n as u64; buf = buf_; break; } @@ -68,7 +68,7 @@ where } } - Ok(transfered) + Ok(transferred) } /// Copy with splice. @@ -83,17 +83,17 @@ pub async fn zero_copy 0 { let written = writer.splice_from_pipe(&mut pr, to_write).await?; to_write -= written; } } - Ok(transfered) + Ok(transferred) } diff --git a/monoio/src/net/mod.rs b/monoio/src/net/mod.rs index 5c26fb2d..ebcdfbda 100644 --- a/monoio/src/net/mod.rs +++ b/monoio/src/net/mod.rs @@ -43,7 +43,7 @@ pub(crate) fn new_socket( #[cfg(unix)] let socket = crate::syscall!(socket(domain, socket_type, 0)); - // Mimick `libstd` and set `SO_NOSIGPIPE` on apple systems. + // Mimic `libstd` and set `SO_NOSIGPIPE` on apple systems. #[cfg(target_vendor = "apple")] let socket = socket.and_then(|socket| { crate::syscall!(setsockopt( diff --git a/monoio/src/net/tcp/listener.rs b/monoio/src/net/tcp/listener.rs index af295091..9cc81d18 100644 --- a/monoio/src/net/tcp/listener.rs +++ b/monoio/src/net/tcp/listener.rs @@ -155,7 +155,7 @@ impl TcpListener { return Err(operation_canceled()); } let op = Op::accept(&self.fd)?; - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); // Await the completion of the event let completion = op.await; diff --git a/monoio/src/net/tcp/stream.rs b/monoio/src/net/tcp/stream.rs index 598d3533..af3fe262 100644 --- a/monoio/src/net/tcp/stream.rs +++ b/monoio/src/net/tcp/stream.rs @@ -363,7 +363,7 @@ impl CancelableAsyncWriteRent for TcpStream { } let op = Op::send(fd, buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.write().await } } @@ -381,7 +381,7 @@ impl CancelableAsyncWriteRent for TcpStream { } let op = Op::writev(&fd, buf_vec).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.write().await } } @@ -450,7 +450,7 @@ impl CancelableAsyncReadRent for TcpStream { } let op = Op::recv(fd, buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.read().await } } @@ -468,7 +468,7 @@ impl CancelableAsyncReadRent for TcpStream { } let op = Op::readv(fd, buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.read().await } } diff --git a/monoio/src/net/udp.rs b/monoio/src/net/udp.rs index a6628d04..c99ed49f 100644 --- a/monoio/src/net/udp.rs +++ b/monoio/src/net/udp.rs @@ -210,7 +210,7 @@ impl UdpSocket { } let op = Op::recv_msg(self.fd.clone(), buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.wait().await } @@ -227,7 +227,7 @@ impl UdpSocket { } let op = Op::send_msg(self.fd.clone(), buf, Some(socket_addr)).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.wait().await } @@ -242,7 +242,7 @@ impl UdpSocket { } let op = Op::send_msg(self.fd.clone(), buf, None).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.wait().await } @@ -258,7 +258,7 @@ impl UdpSocket { } let op = Op::recv(self.fd.clone(), buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.read().await } } diff --git a/monoio/src/net/unix/listener.rs b/monoio/src/net/unix/listener.rs index f3d7cc24..7bb090d0 100644 --- a/monoio/src/net/unix/listener.rs +++ b/monoio/src/net/unix/listener.rs @@ -96,7 +96,7 @@ impl UnixListener { return Err(operation_canceled()); } let op = Op::accept(&self.fd)?; - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); // Await the completion of the event let completion = op.await; diff --git a/monoio/src/net/unix/seq_packet/listener.rs b/monoio/src/net/unix/seq_packet/listener.rs index c40af0d2..28e34121 100644 --- a/monoio/src/net/unix/seq_packet/listener.rs +++ b/monoio/src/net/unix/seq_packet/listener.rs @@ -17,7 +17,7 @@ use crate::{ const DEFAULT_BACKLOG: libc::c_int = 128; -/// Listner for UnixSeqpacket +/// Listener for UnixSeqpacket pub struct UnixSeqpacketListener { fd: SharedFd, } diff --git a/monoio/src/net/unix/stream.rs b/monoio/src/net/unix/stream.rs index 89b1b1c2..decaa25a 100644 --- a/monoio/src/net/unix/stream.rs +++ b/monoio/src/net/unix/stream.rs @@ -234,7 +234,7 @@ impl CancelableAsyncWriteRent for UnixStream { } let op = Op::send(fd, buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.write().await } } @@ -252,7 +252,7 @@ impl CancelableAsyncWriteRent for UnixStream { } let op = Op::writev(&fd, buf_vec).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.write().await } } @@ -316,7 +316,7 @@ impl CancelableAsyncReadRent for UnixStream { } let op = Op::recv(fd, buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.read().await } } @@ -334,7 +334,7 @@ impl CancelableAsyncReadRent for UnixStream { } let op = Op::readv(fd, buf).unwrap(); - let _guard = c.assocate_op(op.op_canceller()); + let _guard = c.associate_op(op.op_canceller()); op.read().await } } diff --git a/monoio/src/utils/slab.rs b/monoio/src/utils/slab.rs index 0075c074..58461137 100644 --- a/monoio/src/utils/slab.rs +++ b/monoio/src/utils/slab.rs @@ -251,7 +251,7 @@ impl Page { } // alloc a slot - // Safety: after slot is allocated, the caller must guarante it will be + // Safety: after slot is allocated, the caller must guarantee it will be // initialized unsafe fn alloc(&mut self) -> Option { let next = self.next;