1
0
Fork 0
forked from wry/wry

all: remove once_cell dependency

This commit is contained in:
Julian Orth 2026-03-30 12:30:26 +02:00
parent c50242562a
commit 41ef632a15
10 changed files with 34 additions and 32 deletions

1
Cargo.lock generated
View file

@ -766,7 +766,6 @@ dependencies = [
"log", "log",
"num-derive", "num-derive",
"num-traits", "num-traits",
"once_cell",
"opera", "opera",
"parking_lot", "parking_lot",
"pin-project", "pin-project",

View file

@ -37,7 +37,6 @@ num-derive = "0.4.2"
libloading = "0.9.0" libloading = "0.9.0"
bstr = { version = "1.9.0", default-features = false, features = ["std"] } bstr = { version = "1.9.0", default-features = false, features = ["std"] }
isnt = "0.2.0" isnt = "0.2.0"
once_cell = "1.19.0"
rand = "0.10.0" rand = "0.10.0"
smallvec = { version = "1.11.1", features = ["const_generics", "const_new", "union"] } smallvec = { version = "1.11.1", features = ["const_generics", "const_new", "union"] }
byteorder = "1.5.0" byteorder = "1.5.0"

View file

@ -1,6 +1,6 @@
use {ahash::AHashMap, once_cell::sync::Lazy}; use {ahash::AHashMap, std::sync::LazyLock};
static BUGS: Lazy<AHashMap<&'static str, Bugs>> = Lazy::new(|| { static BUGS: LazyLock<AHashMap<&'static str, Bugs>> = LazyLock::new(|| {
let mut map = AHashMap::new(); let mut map = AHashMap::new();
map.insert( map.insert(
"chromium", "chromium",

View file

@ -18,7 +18,6 @@ use {
byteorder::{LittleEndian, ReadBytesExt}, byteorder::{LittleEndian, ReadBytesExt},
isnt::std_1::primitive::IsntSliceExt, isnt::std_1::primitive::IsntSliceExt,
num_derive::FromPrimitive, num_derive::FromPrimitive,
once_cell::sync::Lazy,
std::{ std::{
cell::Cell, cell::Cell,
convert::TryInto, convert::TryInto,
@ -29,6 +28,7 @@ use {
mem::MaybeUninit, mem::MaybeUninit,
rc::Rc, rc::Rc,
slice, str, slice, str,
sync::LazyLock,
time::Duration, time::Duration,
}, },
thiserror::Error, thiserror::Error,
@ -46,7 +46,7 @@ const HOME: &str = "HOME";
const HEADER_SIZE: u32 = 16; const HEADER_SIZE: u32 = 16;
pub static DEFAULT_CURSOR_SIZE: Lazy<u32> = Lazy::new(|| { pub static DEFAULT_CURSOR_SIZE: LazyLock<u32> = LazyLock::new(|| {
if let Ok(size) = env::var(XCURSOR_SIZE) if let Ok(size) = env::var(XCURSOR_SIZE)
&& let Ok(val) = size.parse() && let Ok(val) = size.parse()
{ {

View file

@ -13,10 +13,9 @@ use {
ahash::AHashMap, ahash::AHashMap,
ash::vk, ash::vk,
jay_config::video::Format as ConfigFormat, jay_config::video::Format as ConfigFormat,
once_cell::sync::Lazy,
std::{ std::{
fmt, fmt::{self, Debug, Write},
fmt::{Debug, Write}, sync::LazyLock,
}, },
}; };
@ -66,7 +65,7 @@ impl PartialEq for Format {
impl Eq for Format {} impl Eq for Format {}
static FORMATS_MAP: Lazy<AHashMap<u32, &'static Format>> = Lazy::new(|| { static FORMATS_MAP: LazyLock<AHashMap<u32, &'static Format>> = LazyLock::new(|| {
let mut map = AHashMap::new(); let mut map = AHashMap::new();
for format in FORMATS { for format in FORMATS {
assert!(map.insert(format.drm, format).is_none()); assert!(map.insert(format.drm, format).is_none());
@ -74,7 +73,7 @@ static FORMATS_MAP: Lazy<AHashMap<u32, &'static Format>> = Lazy::new(|| {
map map
}); });
static PW_FORMATS_MAP: Lazy<AHashMap<SpaVideoFormat, &'static Format>> = Lazy::new(|| { static PW_FORMATS_MAP: LazyLock<AHashMap<SpaVideoFormat, &'static Format>> = LazyLock::new(|| {
let mut map = AHashMap::new(); let mut map = AHashMap::new();
for format in FORMATS { for format in FORMATS {
if format.pipewire != SPA_VIDEO_FORMAT_UNKNOWN { if format.pipewire != SPA_VIDEO_FORMAT_UNKNOWN {
@ -84,9 +83,9 @@ static PW_FORMATS_MAP: Lazy<AHashMap<SpaVideoFormat, &'static Format>> = Lazy::n
map map
}); });
static FORMATS_REFS: Lazy<Vec<&'static Format>> = Lazy::new(|| FORMATS.iter().collect()); static FORMATS_REFS: LazyLock<Vec<&'static Format>> = LazyLock::new(|| FORMATS.iter().collect());
static FORMATS_NAMES: Lazy<AHashMap<&'static str, &'static Format>> = Lazy::new(|| { static FORMATS_NAMES: LazyLock<AHashMap<&'static str, &'static Format>> = LazyLock::new(|| {
let mut map = AHashMap::new(); let mut map = AHashMap::new();
for format in FORMATS { for format in FORMATS {
assert!(map.insert(format.name, format).is_none()); assert!(map.insert(format.name, format).is_none());
@ -94,7 +93,7 @@ static FORMATS_NAMES: Lazy<AHashMap<&'static str, &'static Format>> = Lazy::new(
map map
}); });
static FORMATS_CONFIG: Lazy<AHashMap<ConfigFormat, &'static Format>> = Lazy::new(|| { static FORMATS_CONFIG: LazyLock<AHashMap<ConfigFormat, &'static Format>> = LazyLock::new(|| {
let mut map = AHashMap::new(); let mut map = AHashMap::new();
for format in FORMATS { for format in FORMATS {
assert!(map.insert(format.config, format).is_none()); assert!(map.insert(format.config, format).is_none());

View file

@ -35,7 +35,7 @@ macro_rules! dynload {
)* )*
} }
pub static $item: once_cell::sync::Lazy<Option<$container>> = once_cell::sync::Lazy::new(|| unsafe { pub static $item: std::sync::LazyLock<Option<$container>> = std::sync::LazyLock::new(|| unsafe {
use crate::utils::errorfmt::ErrorFmt; use crate::utils::errorfmt::ErrorFmt;
let lib = match libloading::Library::new($name) { let lib = match libloading::Library::new($name) {
Ok(l) => l, Ok(l) => l,
@ -94,8 +94,13 @@ use {
}, },
}, },
isnt::std_1::vec::IsntVecExt, isnt::std_1::vec::IsntVecExt,
once_cell::sync::Lazy, std::{
std::{any::Any, cell::RefCell, error::Error, rc::Rc, sync::Arc}, any::Any,
cell::RefCell,
error::Error,
rc::Rc,
sync::{Arc, LazyLock},
},
thiserror::Error, thiserror::Error,
}; };
@ -109,7 +114,8 @@ pub mod sys {
pub use super::{egl::sys::*, gl::sys::*}; pub use super::{egl::sys::*, gl::sys::*};
} }
static INIT: Lazy<Result<(), Arc<RenderError>>> = Lazy::new(|| egl::init().map_err(Arc::new)); static INIT: LazyLock<Result<(), Arc<RenderError>>> =
LazyLock::new(|| egl::init().map_err(Arc::new));
pub(super) fn create_gfx_context( pub(super) fn create_gfx_context(
drm: &Drm, drm: &Drm,

View file

@ -12,8 +12,7 @@ use {
}, },
bstr::ByteSlice, bstr::ByteSlice,
log::Level, log::Level,
once_cell::sync::Lazy, std::{ffi::CStr, sync::LazyLock},
std::ffi::CStr,
sys::{ sys::{
EGL_BAD_ACCESS, EGL_BAD_ALLOC, EGL_BAD_ATTRIBUTE, EGL_BAD_CONFIG, EGL_BAD_CONTEXT, EGL_BAD_ACCESS, EGL_BAD_ALLOC, EGL_BAD_ATTRIBUTE, EGL_BAD_CONFIG, EGL_BAD_CONTEXT,
EGL_BAD_CURRENT_SURFACE, EGL_BAD_DEVICE_EXT, EGL_BAD_DISPLAY, EGL_BAD_MATCH, EGL_BAD_CURRENT_SURFACE, EGL_BAD_DEVICE_EXT, EGL_BAD_DISPLAY, EGL_BAD_MATCH,
@ -28,9 +27,9 @@ pub mod display;
pub mod image; pub mod image;
pub mod sys; pub mod sys;
pub(crate) static PROCS: Lazy<Option<ExtProc>> = Lazy::new(ExtProc::load); pub(crate) static PROCS: LazyLock<Option<ExtProc>> = LazyLock::new(ExtProc::load);
pub(crate) static EXTS: Lazy<ClientExt> = Lazy::new(get_client_ext); pub(crate) static EXTS: LazyLock<ClientExt> = LazyLock::new(get_client_ext);
pub(in crate::gfx_apis::gl) fn init() -> Result<(), RenderError> { pub(in crate::gfx_apis::gl) fn init() -> Result<(), RenderError> {
let Some(egl) = EGL.as_ref() else { let Some(egl) = EGL.as_ref() else {

View file

@ -1,8 +1,8 @@
use { use {
once_cell::sync::Lazy,
std::{ std::{
error::Error, error::Error,
fmt::{Display, Formatter}, fmt::{Display, Formatter},
sync::LazyLock,
}, },
uapi::{ uapi::{
Errno, Errno,
@ -10,7 +10,7 @@ use {
}, },
}; };
static ERRORS: Lazy<&'static [Option<&'static str>]> = Lazy::new(|| { static ERRORS: LazyLock<&'static [Option<&'static str>]> = LazyLock::new(|| {
static MSGS: &[(c::c_int, &str)] = &[ static MSGS: &[(c::c_int, &str)] = &[
(c::EWOULDBLOCK, "Operation would block"), (c::EWOULDBLOCK, "Operation would block"),
(c::ENOTSUP, "Not supported"), (c::ENOTSUP, "Not supported"),

View file

@ -1,6 +1,7 @@
use {once_cell::sync::Lazy, uapi::c}; use {std::sync::LazyLock, uapi::c};
static PAGE_SIZE: Lazy<usize> = Lazy::new(|| uapi::sysconf(c::_SC_PAGESIZE).unwrap_or(4096) as _); static PAGE_SIZE: LazyLock<usize> =
LazyLock::new(|| uapi::sysconf(c::_SC_PAGESIZE).unwrap_or(4096) as _);
pub fn page_size() -> usize { pub fn page_size() -> usize {
*PAGE_SIZE *PAGE_SIZE

View file

@ -18,13 +18,12 @@ use {
}, },
isnt::std_1::collections::IsntHashMapExt, isnt::std_1::collections::IsntHashMapExt,
log::Level, log::Level,
once_cell::sync::Lazy,
run_on_drop::on_drop, run_on_drop::on_drop,
std::{ std::{
ffi::{CStr, CString, c_void}, ffi::{CStr, CString, c_void},
fmt::{Display, Formatter}, fmt::{Display, Formatter},
slice, slice,
sync::Arc, sync::{Arc, LazyLock},
}, },
thiserror::Error, thiserror::Error,
uapi::{Ustr, ustr}, uapi::{Ustr, ustr},
@ -36,11 +35,11 @@ pub mod gpu_alloc_ash;
pub mod sync; pub mod sync;
pub mod timeline_semaphore; pub mod timeline_semaphore;
static VULKAN_ENTRY: Lazy<Result<Entry, Arc<LoadingError>>> = static VULKAN_ENTRY: LazyLock<Result<Entry, Arc<LoadingError>>> =
Lazy::new(|| unsafe { Entry::load() }.map_err(Arc::new)); LazyLock::new(|| unsafe { Entry::load() }.map_err(Arc::new));
static VULKAN_VALIDATION: Lazy<bool> = static VULKAN_VALIDATION: LazyLock<bool> =
Lazy::new(|| std::env::var("JAY_VULKAN_VALIDATION").ok().as_deref() == Some("1")); LazyLock::new(|| std::env::var("JAY_VULKAN_VALIDATION").ok().as_deref() == Some("1"));
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum VulkanCoreError { pub enum VulkanCoreError {