mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-07 00:00:09 +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.
|
||||
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() }))
|
||||
}
|
||||
|
||||
|
||||
@@ -171,20 +171,20 @@ fn try_recv() {
|
||||
assert_ok!(ctx.tx.clone().try_send(()));
|
||||
}
|
||||
|
||||
let mut ths = Vec::new();
|
||||
let mut threads = Vec::new();
|
||||
|
||||
for _ in 0..TASKS {
|
||||
let ctx = ctx.clone();
|
||||
|
||||
ths.push(thread::spawn(move || {
|
||||
threads.push(thread::spawn(move || {
|
||||
run(&ctx);
|
||||
}));
|
||||
}
|
||||
|
||||
run(&ctx);
|
||||
|
||||
for th in ths {
|
||||
th.join().unwrap();
|
||||
for thread in threads {
|
||||
thread.join().unwrap();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ fn notify_multi() {
|
||||
loom::model(|| {
|
||||
let notify = Arc::new(Notify::new());
|
||||
|
||||
let mut ths = vec![];
|
||||
let mut threads = vec![];
|
||||
|
||||
for _ in 0..2 {
|
||||
let notify = notify.clone();
|
||||
|
||||
ths.push(thread::spawn(move || {
|
||||
threads.push(thread::spawn(move || {
|
||||
block_on(async {
|
||||
notify.notified().await;
|
||||
notify.notify_one();
|
||||
@@ -96,8 +96,8 @@ fn notify_multi() {
|
||||
|
||||
notify.notify_one();
|
||||
|
||||
for th in ths.drain(..) {
|
||||
th.join().unwrap();
|
||||
for thread in threads.drain(..) {
|
||||
thread.join().unwrap();
|
||||
}
|
||||
|
||||
block_on(async {
|
||||
|
||||
@@ -164,13 +164,13 @@ fn batch() {
|
||||
b.check(|| {
|
||||
let semaphore = Arc::new(Semaphore::new(10));
|
||||
let active = Arc::new(AtomicUsize::new(0));
|
||||
let mut ths = vec![];
|
||||
let mut threads = vec![];
|
||||
|
||||
for _ in 0..2 {
|
||||
let semaphore = semaphore.clone();
|
||||
let active = active.clone();
|
||||
|
||||
ths.push(thread::spawn(move || {
|
||||
threads.push(thread::spawn(move || {
|
||||
for n in &[4, 10, 8] {
|
||||
block_on(semaphore.acquire(*n)).unwrap();
|
||||
|
||||
@@ -188,8 +188,8 @@ fn batch() {
|
||||
}));
|
||||
}
|
||||
|
||||
for th in ths.into_iter() {
|
||||
th.join().unwrap();
|
||||
for thread in threads.into_iter() {
|
||||
thread.join().unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(10, semaphore.available_permits());
|
||||
|
||||
@@ -449,7 +449,7 @@ impl Future for Sleep {
|
||||
//
|
||||
// - AtCapacity: this is a pathological case where far too many
|
||||
// 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
|
||||
// "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)?;
|
||||
|
||||
// Check if Receiver detects write-only access mode.
|
||||
let wronly = std::fs::OpenOptions::new()
|
||||
let write_only = std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.custom_flags(libc::O_NONBLOCK)
|
||||
.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);
|
||||
|
||||
// Check if Sender detects read-only access mode.
|
||||
@@ -298,9 +298,9 @@ async fn from_file_sets_nonblock() -> io::Result<()> {
|
||||
assert!(is_nonblocking(&reader)?);
|
||||
|
||||
// Check if Sender sets the pipe in non-blocking mode.
|
||||
let wronly = std::fs::OpenOptions::new().write(true).open(&fifo)?;
|
||||
assert!(!is_nonblocking(&wronly)?);
|
||||
let writer = pipe::Sender::from_file(wronly)?;
|
||||
let write_only = std::fs::OpenOptions::new().write(true).open(&fifo)?;
|
||||
assert!(!is_nonblocking(&write_only)?);
|
||||
let writer = pipe::Sender::from_file(write_only)?;
|
||||
assert!(is_nonblocking(&writer)?);
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -365,13 +365,13 @@ mod unstable {
|
||||
.unwrap();
|
||||
|
||||
let rt = Arc::new(rt);
|
||||
let mut ths = vec![];
|
||||
let mut threads = vec![];
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
for _ in 0..N {
|
||||
let rt = rt.clone();
|
||||
let tx = tx.clone();
|
||||
ths.push(std::thread::spawn(move || {
|
||||
threads.push(std::thread::spawn(move || {
|
||||
rt.block_on(async {
|
||||
tx.send(()).unwrap();
|
||||
futures::future::pending::<()>().await;
|
||||
@@ -387,8 +387,8 @@ mod unstable {
|
||||
panic!("boom");
|
||||
});
|
||||
|
||||
for th in ths {
|
||||
assert!(th.join().is_err());
|
||||
for thread in threads {
|
||||
assert!(thread.join().is_err());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user