mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
chore: fix minor typos (#7804)
This commit is contained in:
@@ -170,7 +170,7 @@ impl<T> Block<T> {
|
|||||||
// 2. The `UnsafeCell` always give us a valid pointer to the value.
|
// 2. The `UnsafeCell` always give us a valid pointer to the value.
|
||||||
let value = self.values[offset].with(|ptr| unsafe { ptr::read(ptr) });
|
let value = self.values[offset].with(|ptr| unsafe { ptr::read(ptr) });
|
||||||
|
|
||||||
// Safety: the redy bit is set, so the value has been initialized.
|
// Safety: the ready bit is set, so the value has been initialized.
|
||||||
Some(Read::Value(unsafe { value.assume_init() }))
|
Some(Read::Value(unsafe { value.assume_init() }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,20 +171,20 @@ fn try_recv() {
|
|||||||
assert_ok!(ctx.tx.clone().try_send(()));
|
assert_ok!(ctx.tx.clone().try_send(()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ths = Vec::new();
|
let mut threads = Vec::new();
|
||||||
|
|
||||||
for _ in 0..TASKS {
|
for _ in 0..TASKS {
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
|
|
||||||
ths.push(thread::spawn(move || {
|
threads.push(thread::spawn(move || {
|
||||||
run(&ctx);
|
run(&ctx);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
run(&ctx);
|
run(&ctx);
|
||||||
|
|
||||||
for th in ths {
|
for thread in threads {
|
||||||
th.join().unwrap();
|
thread.join().unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ fn notify_multi() {
|
|||||||
loom::model(|| {
|
loom::model(|| {
|
||||||
let notify = Arc::new(Notify::new());
|
let notify = Arc::new(Notify::new());
|
||||||
|
|
||||||
let mut ths = vec![];
|
let mut threads = vec![];
|
||||||
|
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
let notify = notify.clone();
|
let notify = notify.clone();
|
||||||
|
|
||||||
ths.push(thread::spawn(move || {
|
threads.push(thread::spawn(move || {
|
||||||
block_on(async {
|
block_on(async {
|
||||||
notify.notified().await;
|
notify.notified().await;
|
||||||
notify.notify_one();
|
notify.notify_one();
|
||||||
@@ -96,8 +96,8 @@ fn notify_multi() {
|
|||||||
|
|
||||||
notify.notify_one();
|
notify.notify_one();
|
||||||
|
|
||||||
for th in ths.drain(..) {
|
for thread in threads.drain(..) {
|
||||||
th.join().unwrap();
|
thread.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
block_on(async {
|
block_on(async {
|
||||||
|
|||||||
@@ -164,13 +164,13 @@ fn batch() {
|
|||||||
b.check(|| {
|
b.check(|| {
|
||||||
let semaphore = Arc::new(Semaphore::new(10));
|
let semaphore = Arc::new(Semaphore::new(10));
|
||||||
let active = Arc::new(AtomicUsize::new(0));
|
let active = Arc::new(AtomicUsize::new(0));
|
||||||
let mut ths = vec![];
|
let mut threads = vec![];
|
||||||
|
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
let semaphore = semaphore.clone();
|
let semaphore = semaphore.clone();
|
||||||
let active = active.clone();
|
let active = active.clone();
|
||||||
|
|
||||||
ths.push(thread::spawn(move || {
|
threads.push(thread::spawn(move || {
|
||||||
for n in &[4, 10, 8] {
|
for n in &[4, 10, 8] {
|
||||||
block_on(semaphore.acquire(*n)).unwrap();
|
block_on(semaphore.acquire(*n)).unwrap();
|
||||||
|
|
||||||
@@ -188,8 +188,8 @@ fn batch() {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
for th in ths.into_iter() {
|
for thread in threads.into_iter() {
|
||||||
th.join().unwrap();
|
thread.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(10, semaphore.available_permits());
|
assert_eq!(10, semaphore.available_permits());
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ impl Future for Sleep {
|
|||||||
//
|
//
|
||||||
// - AtCapacity: this is a pathological case where far too many
|
// - AtCapacity: this is a pathological case where far too many
|
||||||
// sleep instances have been scheduled.
|
// sleep instances have been scheduled.
|
||||||
// - Shutdown: No timer has been setup, which is a mis-use error.
|
// - Shutdown: No timer has been setup, which is a misuse error.
|
||||||
//
|
//
|
||||||
// Both cases are extremely rare, and pretty accurately fit into
|
// Both cases are extremely rare, and pretty accurately fit into
|
||||||
// "logic errors", so we just panic in this case. A user couldn't
|
// "logic errors", so we just panic in this case. A user couldn't
|
||||||
|
|||||||
@@ -259,11 +259,11 @@ async fn from_file_detects_wrong_access_mode() -> io::Result<()> {
|
|||||||
let _reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
|
let _reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
|
||||||
|
|
||||||
// Check if Receiver detects write-only access mode.
|
// Check if Receiver detects write-only access mode.
|
||||||
let wronly = std::fs::OpenOptions::new()
|
let write_only = std::fs::OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.custom_flags(libc::O_NONBLOCK)
|
.custom_flags(libc::O_NONBLOCK)
|
||||||
.open(&fifo)?;
|
.open(&fifo)?;
|
||||||
let err = assert_err!(pipe::Receiver::from_file(wronly));
|
let err = assert_err!(pipe::Receiver::from_file(write_only));
|
||||||
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
|
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
|
||||||
|
|
||||||
// Check if Sender detects read-only access mode.
|
// Check if Sender detects read-only access mode.
|
||||||
@@ -298,9 +298,9 @@ async fn from_file_sets_nonblock() -> io::Result<()> {
|
|||||||
assert!(is_nonblocking(&reader)?);
|
assert!(is_nonblocking(&reader)?);
|
||||||
|
|
||||||
// Check if Sender sets the pipe in non-blocking mode.
|
// Check if Sender sets the pipe in non-blocking mode.
|
||||||
let wronly = std::fs::OpenOptions::new().write(true).open(&fifo)?;
|
let write_only = std::fs::OpenOptions::new().write(true).open(&fifo)?;
|
||||||
assert!(!is_nonblocking(&wronly)?);
|
assert!(!is_nonblocking(&write_only)?);
|
||||||
let writer = pipe::Sender::from_file(wronly)?;
|
let writer = pipe::Sender::from_file(write_only)?;
|
||||||
assert!(is_nonblocking(&writer)?);
|
assert!(is_nonblocking(&writer)?);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -365,13 +365,13 @@ mod unstable {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let rt = Arc::new(rt);
|
let rt = Arc::new(rt);
|
||||||
let mut ths = vec![];
|
let mut threads = vec![];
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
for _ in 0..N {
|
for _ in 0..N {
|
||||||
let rt = rt.clone();
|
let rt = rt.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
ths.push(std::thread::spawn(move || {
|
threads.push(std::thread::spawn(move || {
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
tx.send(()).unwrap();
|
tx.send(()).unwrap();
|
||||||
futures::future::pending::<()>().await;
|
futures::future::pending::<()>().await;
|
||||||
@@ -387,8 +387,8 @@ mod unstable {
|
|||||||
panic!("boom");
|
panic!("boom");
|
||||||
});
|
});
|
||||||
|
|
||||||
for th in ths {
|
for thread in threads {
|
||||||
assert!(th.join().is_err());
|
assert!(thread.join().is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user