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

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();
map.insert(
"chromium",

View file

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

View file

@ -13,10 +13,9 @@ use {
ahash::AHashMap,
ash::vk,
jay_config::video::Format as ConfigFormat,
once_cell::sync::Lazy,
std::{
fmt,
fmt::{Debug, Write},
fmt::{self, Debug, Write},
sync::LazyLock,
},
};
@ -66,7 +65,7 @@ impl PartialEq 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();
for format in FORMATS {
assert!(map.insert(format.drm, format).is_none());
@ -74,7 +73,7 @@ static FORMATS_MAP: Lazy<AHashMap<u32, &'static Format>> = Lazy::new(|| {
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();
for format in FORMATS {
if format.pipewire != SPA_VIDEO_FORMAT_UNKNOWN {
@ -84,9 +83,9 @@ static PW_FORMATS_MAP: Lazy<AHashMap<SpaVideoFormat, &'static Format>> = Lazy::n
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();
for format in FORMATS {
assert!(map.insert(format.name, format).is_none());
@ -94,7 +93,7 @@ static FORMATS_NAMES: Lazy<AHashMap<&'static str, &'static Format>> = Lazy::new(
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();
for format in FORMATS {
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;
let lib = match libloading::Library::new($name) {
Ok(l) => l,
@ -94,8 +94,13 @@ use {
},
},
isnt::std_1::vec::IsntVecExt,
once_cell::sync::Lazy,
std::{any::Any, cell::RefCell, error::Error, rc::Rc, sync::Arc},
std::{
any::Any,
cell::RefCell,
error::Error,
rc::Rc,
sync::{Arc, LazyLock},
},
thiserror::Error,
};
@ -109,7 +114,8 @@ pub mod 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(
drm: &Drm,

View file

@ -12,8 +12,7 @@ use {
},
bstr::ByteSlice,
log::Level,
once_cell::sync::Lazy,
std::ffi::CStr,
std::{ffi::CStr, sync::LazyLock},
sys::{
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,
@ -28,9 +27,9 @@ pub mod display;
pub mod image;
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> {
let Some(egl) = EGL.as_ref() else {

View file

@ -1,8 +1,8 @@
use {
once_cell::sync::Lazy,
std::{
error::Error,
fmt::{Display, Formatter},
sync::LazyLock,
},
uapi::{
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)] = &[
(c::EWOULDBLOCK, "Operation would block"),
(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 {
*PAGE_SIZE

View file

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