mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 05:27:08 -04:00
refactor: migrate from lazy_static to once_cell (#1210)
This commit is contained in:
parent
5dce1eaeef
commit
9394983d15
5 changed files with 9 additions and 13 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -839,9 +839,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.9.0"
|
version = "1.17.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
|
@ -1188,7 +1188,7 @@ dependencies = [
|
||||||
"align-data",
|
"align-data",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"fslock",
|
"fslock",
|
||||||
"lazy_static",
|
"once_cell",
|
||||||
"trybuild",
|
"trybuild",
|
||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
|
@ -80,7 +80,7 @@ use_custom_libcxx = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.3.2"
|
bitflags = "1.3.2"
|
||||||
lazy_static = "1.4.0"
|
once_cell = "1.17.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
fslock = "0.1.8"
|
fslock = "0.1.8"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
@ -71,9 +72,8 @@ enum GlobalState {
|
||||||
}
|
}
|
||||||
use GlobalState::*;
|
use GlobalState::*;
|
||||||
|
|
||||||
lazy_static! {
|
static GLOBAL_STATE: Lazy<Mutex<GlobalState>> =
|
||||||
static ref GLOBAL_STATE: Mutex<GlobalState> = Mutex::new(Uninitialized);
|
Lazy::new(|| Mutex::new(Uninitialized));
|
||||||
}
|
|
||||||
|
|
||||||
pub fn assert_initialized() {
|
pub fn assert_initialized() {
|
||||||
let global_state_guard = GLOBAL_STATE.lock().unwrap();
|
let global_state_guard = GLOBAL_STATE.lock().unwrap();
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
mod array_buffer;
|
mod array_buffer;
|
||||||
mod array_buffer_view;
|
mod array_buffer_view;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use std::any::type_name;
|
use std::any::type_name;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
@ -7480,9 +7480,7 @@ fn counter_lookup_callback() {
|
||||||
unsafe impl Send for Name {}
|
unsafe impl Send for Name {}
|
||||||
unsafe impl Send for Count {}
|
unsafe impl Send for Count {}
|
||||||
|
|
||||||
lazy_static! {
|
static MAP: Lazy<Arc<Mutex<HashMap<Name, Count>>>> = Lazy::new(Arc::default);
|
||||||
static ref MAP: Arc<Mutex<HashMap<Name, Count>>> = Arc::default();
|
|
||||||
}
|
|
||||||
|
|
||||||
// |name| points to a static zero-terminated C string.
|
// |name| points to a static zero-terminated C string.
|
||||||
extern "C" fn callback(name: *const c_char) -> *mut i32 {
|
extern "C" fn callback(name: *const c_char) -> *mut i32 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue