Skip to content

Commit 1d9359f

Browse files
WIP: refactor(core): use std instead of once_cell
Currently only possible on Nightly Rust, because `wgpu-core` needs [`std::sync::OnceLock::get_or_try_init`]. [`std::sync::OnceLock::get_or_try_init`]: https://doc.rust-lang.org/stable/std/sync/struct.OnceLock.html#method.get_or_try_init
1 parent 894d036 commit 1d9359f

4 files changed

Lines changed: 3 additions & 8 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ nanorand = { version = "0.7", default-features = false, features = ["wyrand"] }
125125
noise = "0.9"
126126
nv-flip = "0.1"
127127
obj = "0.10"
128-
# NOTE: once_cell/std is *required* for some commonly-used features, selecting this per crate
129-
once_cell = { version = "1.21.1", default-features = false }
130128
# Firefox has 3.4.0 vendored, so we allow that version in our dependencies
131129
ordered-float = { version = ">=3,<=4.6", default-features = false }
132130
parking_lot = "0.12.1"

wgpu-core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ document-features.workspace = true
188188
hashbrown.workspace = true
189189
indexmap.workspace = true
190190
log.workspace = true
191-
once_cell = { workspace = true, features = ["std"] }
192191
parking_lot.workspace = true
193192
profiling = { workspace = true, default-features = false }
194193
raw-window-handle = { workspace = true, optional = true }

wgpu-core/src/pool.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
use alloc::sync::{Arc, Weak};
1+
use alloc::sync::{Arc, OnceLock, Weak};
22
use core::hash::Hash;
33

44
use hashbrown::{hash_map::Entry, HashMap};
5-
use once_cell::sync::OnceCell;
65

76
use crate::lock::{rank, Mutex};
87
use crate::FastHashMap;
98

109
type SlotInner<V> = Weak<V>;
11-
type ResourcePoolSlot<V> = Arc<OnceCell<SlotInner<V>>>;
10+
type ResourcePoolSlot<V> = Arc<OnceLock<SlotInner<V>>>;
1211

1312
pub struct ResourcePool<K, V> {
1413
inner: Mutex<FastHashMap<K, ResourcePoolSlot<V>>>,
@@ -50,7 +49,7 @@ impl<K: Clone + Eq + Hash, V> ResourcePool<K, V> {
5049
// No entry exists for this resource.
5150
//
5251
// We know that the resource is not alive, so we can create a new entry.
53-
Entry::Vacant(entry) => Arc::clone(entry.insert(Arc::new(OnceCell::new()))),
52+
Entry::Vacant(entry) => Arc::clone(entry.insert(Arc::new(OnceLock::new()))),
5453
};
5554

5655
drop(map_guard);

0 commit comments

Comments
 (0)