Replace the lazy_static crate with std::sync::LazyLock in components/net (#33046)

* replace in net/fetch/methods.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in net/hosts.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in net/async_runtime.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in net/tests/main.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* remove lazy_static crate from components/net

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

---------

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
Hayashi Mikihiro 2024-08-14 21:15:55 +09:00 committed by GitHub
parent 6be99241c6
commit 65f90ff1fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 15 additions and 26 deletions

View file

@ -23,7 +23,7 @@ use std::fs::File;
use std::io::{self, BufReader};
use std::net::TcpListener as StdTcpListener;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, Weak};
use std::sync::{Arc, LazyLock, Mutex, Weak};
use crossbeam_channel::{unbounded, Sender};
use devtools_traits::DevtoolsControlMsg;
@ -34,7 +34,6 @@ use hyper::server::conn::Http;
use hyper::server::Server as HyperServer;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request as HyperRequest, Response as HyperResponse};
use lazy_static::lazy_static;
use net::fetch::cors_cache::CorsCache;
use net::fetch::methods::{self, CancellationListener, FetchContext};
use net::filemanager_thread::FileManager;
@ -54,15 +53,15 @@ use tokio_rustls::{self, TlsAcceptor};
use tokio_stream::wrappers::TcpListenerStream;
use tokio_test::block_on;
lazy_static! {
pub static ref HANDLE: Mutex<Runtime> = Mutex::new(
pub static HANDLE: LazyLock<Mutex<Runtime>> = LazyLock::new(|| {
Mutex::new(
Builder::new_multi_thread()
.enable_io()
.worker_threads(10)
.build()
.unwrap()
);
}
.unwrap(),
)
});
const DEFAULT_USER_AGENT: &'static str = "Such Browser. Very Layout. Wow.";