From 0dbba139848de6a8ee88350cc7fc48d0b05016c5 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Fri, 4 Dec 2020 10:23:13 +0100 Subject: deps: replace lazy_static with once_cell (#3187) --- tokio/Cargo.toml | 7 +++---- tokio/src/process/unix/mod.rs | 5 ++--- tokio/src/signal/registry.rs | 10 +++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 15ba7179..ad56ef02 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -50,7 +50,6 @@ io-util = ["memchr", "bytes"] io-std = [] macros = ["tokio-macros"] net = [ - "lazy_static", "libc", "mio/os-poll", "mio/os-util", @@ -60,7 +59,7 @@ net = [ ] process = [ "bytes", - "lazy_static", + "once_cell", "libc", "mio/os-poll", "mio/os-util", @@ -75,7 +74,7 @@ rt-multi-thread = [ "rt", ] signal = [ - "lazy_static", + "once_cell", "libc", "mio/os-poll", "mio/uds", @@ -96,7 +95,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 } diff --git a/tokio/src/process/unix/mod.rs b/tokio/src/process/unix/mod.rs index 966c2a28..3608b9f1 100644 --- a/tokio/src/process/unix/mod.rs +++ b/tokio/src/process/unix/mod.rs @@ -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; @@ -62,9 +63,7 @@ impl Kill for StdChild { } } -lazy_static::lazy_static! { - static ref ORPHAN_QUEUE: OrphanQueueImpl = OrphanQueueImpl::new(); -} +static ORPHAN_QUEUE: Lazy> = Lazy::new(OrphanQueueImpl::new); pub(crate) struct GlobalOrphanQueue; diff --git a/tokio/src/signal/registry.rs b/tokio/src/signal/registry.rs index 5d6f608c..55ee8c53 100644 --- a/tokio/src/signal/registry.rs +++ b/tokio/src/signal/registry.rs @@ -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}; @@ -165,12 +165,12 @@ where OsExtraData: 'static + Send + Sync + Init, OsStorage: 'static + Send + Sync + Init, { - lazy_static! { - static ref GLOBALS: Pin> = Box::pin(Globals { + static GLOBALS: Lazy>> = Lazy::new(|| { + Box::pin(Globals { extra: OsExtraData::init(), registry: Registry::new(OsStorage::init()), - }); - } + }) + }); GLOBALS.as_ref() } -- cgit v1.2.3