Skip to content

Commit 0dbba13

Browse files
authored
deps: replace lazy_static with once_cell (#3187)
1 parent a125ebd commit 0dbba13

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

tokio/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ io-util = ["memchr", "bytes"]
5050
io-std = []
5151
macros = ["tokio-macros"]
5252
net = [
53-
"lazy_static",
5453
"libc",
5554
"mio/os-poll",
5655
"mio/os-util",
@@ -60,7 +59,7 @@ net = [
6059
]
6160
process = [
6261
"bytes",
63-
"lazy_static",
62+
"once_cell",
6463
"libc",
6564
"mio/os-poll",
6665
"mio/os-util",
@@ -75,7 +74,7 @@ rt-multi-thread = [
7574
"rt",
7675
]
7776
signal = [
78-
"lazy_static",
77+
"once_cell",
7978
"libc",
8079
"mio/os-poll",
8180
"mio/uds",
@@ -96,7 +95,7 @@ pin-project-lite = "0.2.0"
9695
# Everything else is optional...
9796
bytes = { version = "0.6.0", optional = true }
9897
futures-core = { version = "0.3.0", optional = true }
99-
lazy_static = { version = "1.4.0", optional = true }
98+
once_cell = { version = "1.5.2", optional = true }
10099
memchr = { version = "2.2", optional = true }
101100
mio = { version = "0.7.6", optional = true }
102101
num_cpus = { version = "1.8.0", optional = true }

tokio/src/process/unix/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::signal::unix::{signal, Signal, SignalKind};
3636

3737
use mio::event::Source;
3838
use mio::unix::SourceFd;
39+
use once_cell::sync::Lazy;
3940
use std::fmt;
4041
use std::fs::File;
4142
use std::future::Future;
@@ -62,9 +63,7 @@ impl Kill for StdChild {
6263
}
6364
}
6465

65-
lazy_static::lazy_static! {
66-
static ref ORPHAN_QUEUE: OrphanQueueImpl<StdChild> = OrphanQueueImpl::new();
67-
}
66+
static ORPHAN_QUEUE: Lazy<OrphanQueueImpl<StdChild>> = Lazy::new(OrphanQueueImpl::new);
6867

6968
pub(crate) struct GlobalOrphanQueue;
7069

tokio/src/signal/registry.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::signal::os::{OsExtraData, OsStorage};
44

55
use crate::sync::mpsc::Sender;
66

7-
use lazy_static::lazy_static;
7+
use once_cell::sync::Lazy;
88
use std::ops;
99
use std::pin::Pin;
1010
use std::sync::atomic::{AtomicBool, Ordering};
@@ -165,12 +165,12 @@ where
165165
OsExtraData: 'static + Send + Sync + Init,
166166
OsStorage: 'static + Send + Sync + Init,
167167
{
168-
lazy_static! {
169-
static ref GLOBALS: Pin<Box<Globals>> = Box::pin(Globals {
168+
static GLOBALS: Lazy<Pin<Box<Globals>>> = Lazy::new(|| {
169+
Box::pin(Globals {
170170
extra: OsExtraData::init(),
171171
registry: Registry::new(OsStorage::init()),
172-
});
173-
}
172+
})
173+
});
174174

175175
GLOBALS.as_ref()
176176
}

0 commit comments

Comments
 (0)