refactor: remove once_cell dependency and use std::sync equivalents (#4185)
This commit is contained in:
1 parent
1d954c2f6f
commit
3c3256ec02
22 files changed
+22
-47
No files matched your search
@@ -39,7 +39,6 @@ dioxus-interpreter-js = { workspace = true, optional = true }
|
||||
|
||||
tracing = { workspace = true }
|
||||
tracing-futures = { workspace = true }
|
||||
once_cell = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
enumset = "1.1.5"
|
||||
@@ -108,4 +107,3 @@ aws-lc-rs = ["dep:aws-lc-rs"]
|
||||
[package.metadata.docs.rs]
|
||||
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
||||
features = ["axum", "web", "aws-lc-rs"]
|
||||
|
||||
@@ -6,10 +6,10 @@ use std::cell::RefCell;
|
||||
|
||||
use dioxus_lib::{document::*, prelude::*};
|
||||
use dioxus_ssr::Renderer;
|
||||
use once_cell::sync::Lazy;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
static RENDERER: Lazy<RwLock<Renderer>> = Lazy::new(|| RwLock::new(Renderer::new()));
|
||||
static RENDERER: LazyLock<RwLock<Renderer>> = LazyLock::new(|| RwLock::new(Renderer::new()));
|
||||
|
||||
/// Reset the static renderer to a fresh state, clearing its cache.
|
||||
pub(crate) fn reset_renderer() {
|
||||
|
||||
@@ -331,7 +331,7 @@ pub(crate) fn add_server_context(
|
||||
pub struct RenderHandleState {
|
||||
config: ServeConfig,
|
||||
build_virtual_dom: Arc<dyn Fn() -> VirtualDom + Send + Sync>,
|
||||
ssr_state: once_cell::sync::OnceCell<SSRState>,
|
||||
ssr_state: std::sync::OnceLock<SSRState>,
|
||||
}
|
||||
|
||||
impl RenderHandleState {
|
||||
@@ -364,7 +364,7 @@ impl RenderHandleState {
|
||||
|
||||
/// Set the [`SSRState`] for this [`RenderHandleState`]. Sharing a [`SSRState`] between multiple [`RenderHandleState`]s is more efficient than creating a new [`SSRState`] for each [`RenderHandleState`].
|
||||
pub fn with_ssr_state(mut self, ssr_state: SSRState) -> Self {
|
||||
self.ssr_state = once_cell::sync::OnceCell::new();
|
||||
self.ssr_state = std::sync::OnceLock::new();
|
||||
if self.ssr_state.set(ssr_state).is_err() {
|
||||
panic!("SSRState already set");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user