Skip to content

Commit 8507e28

Browse files
authored
Remove an old custom OnceCell implementation in favor of std (#7208)
1 parent 7efcab4 commit 8507e28

File tree

5 files changed

+10
-83
lines changed

5 files changed

+10
-83
lines changed

tokio/src/loom/std/atomic_u64_static_once_cell.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::AtomicU64;
22
use crate::loom::sync::{atomic::Ordering, Mutex};
3-
use crate::util::once_cell::OnceCell;
3+
use std::sync::OnceLock;
44

55
pub(crate) struct StaticAtomicU64 {
66
init: u64,
7-
cell: OnceCell<Mutex<u64>>,
7+
cell: OnceLock<Mutex<u64>>,
88
}
99

1010
impl AtomicU64 {
@@ -19,7 +19,7 @@ impl StaticAtomicU64 {
1919
pub(crate) const fn new(val: u64) -> StaticAtomicU64 {
2020
StaticAtomicU64 {
2121
init: val,
22-
cell: OnceCell::new(),
22+
cell: OnceLock::new(),
2323
}
2424
}
2525

@@ -52,6 +52,6 @@ impl StaticAtomicU64 {
5252
}
5353

5454
fn inner(&self) -> &Mutex<u64> {
55-
self.cell.get(|| Mutex::new(self.init))
55+
self.cell.get_or_init(|| Mutex::new(self.init))
5656
}
5757
}

tokio/src/process/unix/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ impl Kill for StdChild {
6666

6767
cfg_not_has_const_mutex_new! {
6868
fn get_orphan_queue() -> &'static OrphanQueueImpl<StdChild> {
69-
use crate::util::once_cell::OnceCell;
69+
use std::sync::OnceLock;
7070

71-
static ORPHAN_QUEUE: OnceCell<OrphanQueueImpl<StdChild>> = OnceCell::new();
71+
static ORPHAN_QUEUE: OnceLock<OrphanQueueImpl<StdChild>> = OnceLock::new();
7272

73-
ORPHAN_QUEUE.get(OrphanQueueImpl::new)
73+
ORPHAN_QUEUE.get_or_init(OrphanQueueImpl::new)
7474
}
7575
}
7676

tokio/src/signal/registry.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::signal::os::{OsExtraData, OsStorage};
22
use crate::sync::watch;
3-
use crate::util::once_cell::OnceCell;
43

54
use std::ops;
65
use std::sync::atomic::{AtomicBool, Ordering};
6+
use std::sync::OnceLock;
77

88
pub(crate) type EventId = usize;
99

@@ -164,9 +164,9 @@ where
164164
OsExtraData: 'static + Send + Sync + Init,
165165
OsStorage: 'static + Send + Sync + Init,
166166
{
167-
static GLOBALS: OnceCell<Globals> = OnceCell::new();
167+
static GLOBALS: OnceLock<Globals> = OnceLock::new();
168168

169-
GLOBALS.get(globals_init)
169+
GLOBALS.get_or_init(globals_init)
170170
}
171171

172172
#[cfg(all(test, not(loom)))]

tokio/src/util/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ pub(crate) use blocking_check::check_socket_for_blocking;
1313

1414
pub(crate) mod metric_atomics;
1515

16-
#[cfg(any(feature = "rt", feature = "signal", feature = "process"))]
17-
pub(crate) mod once_cell;
18-
1916
#[cfg(any(
2017
// io driver uses `WakeList` directly
2118
feature = "net",

tokio/src/util/once_cell.rs

-70
This file was deleted.

0 commit comments

Comments
 (0)