Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace lazy_static with once_cell #3187

Merged
merged 3 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ io-util = ["memchr", "bytes"]
io-std = []
macros = ["tokio-macros"]
net = [
"lazy_static",
Razican marked this conversation as resolved.
Show resolved Hide resolved
"once_cell",
"libc",
"mio/os-poll",
"mio/os-util",
Expand All @@ -60,7 +60,7 @@ net = [
]
process = [
"bytes",
"lazy_static",
"once_cell",
"libc",
"mio/os-poll",
"mio/os-util",
Expand All @@ -75,7 +75,7 @@ rt-multi-thread = [
"rt",
]
signal = [
"lazy_static",
"once_cell",
"libc",
"mio/os-poll",
"mio/uds",
Expand All @@ -96,7 +96,7 @@ pin-project-lite = "0.2.0"
# Everything else is optional...
bytes = { version = "0.6.0", optional = true }
futures-core = { version = "0.3.0", optional = true }
lazy_static = { version = "1.4.0", optional = true }
once_cell = { version = "1.5.2", optional = true }
memchr = { version = "2.2", optional = true }
mio = { version = "0.7.6", optional = true }
num_cpus = { version = "1.8.0", optional = true }
Expand Down
5 changes: 2 additions & 3 deletions tokio/src/process/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::signal::unix::{signal, Signal, SignalKind};

use mio::event::Source;
use mio::unix::SourceFd;
use once_cell::sync::Lazy;
use std::fmt;
use std::fs::File;
use std::future::Future;
Expand All @@ -62,9 +63,7 @@ impl Kill for StdChild {
}
}

lazy_static::lazy_static! {
static ref ORPHAN_QUEUE: OrphanQueueImpl<StdChild> = OrphanQueueImpl::new();
}
static ORPHAN_QUEUE: Lazy<OrphanQueueImpl<StdChild>> = Lazy::new(|| OrphanQueueImpl::new());
Razican marked this conversation as resolved.
Show resolved Hide resolved

pub(crate) struct GlobalOrphanQueue;

Expand Down
10 changes: 5 additions & 5 deletions tokio/src/signal/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::signal::os::{OsExtraData, OsStorage};

use crate::sync::mpsc::Sender;

use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use std::ops;
use std::pin::Pin;
use std::sync::atomic::{AtomicBool, Ordering};
Expand Down Expand Up @@ -165,12 +165,12 @@ where
OsExtraData: 'static + Send + Sync + Init,
OsStorage: 'static + Send + Sync + Init,
{
lazy_static! {
static ref GLOBALS: Pin<Box<Globals>> = Box::pin(Globals {
static GLOBALS: Lazy<Pin<Box<Globals>>> = Lazy::new(|| {
Box::pin(Globals {
extra: OsExtraData::init(),
registry: Registry::new(OsStorage::init()),
});
}
})
});

GLOBALS.as_ref()
}
Expand Down