⬆️ Replace LazyStatic with new std::sync::LazyLock
This commit is contained in:
parent
2caa7e924b
commit
dfb34d2e36
13 changed files with 67 additions and 62 deletions
|
|
@ -1,12 +1,11 @@
|
|||
use crate::core::action::{ActionBox, ActionKey, ActionTrait, ActionsList};
|
||||
use crate::LazyStatic;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::RwLock;
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
// Registered actions.
|
||||
static ACTIONS: LazyStatic<RwLock<HashMap<ActionKey, ActionsList>>> =
|
||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||
static ACTIONS: LazyLock<RwLock<HashMap<ActionKey, ActionsList>>> =
|
||||
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
pub fn add_action(action: ActionBox) {
|
||||
let key = action.key();
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
use crate::core::action::add_action;
|
||||
use crate::core::package::PackageRef;
|
||||
use crate::core::theme::all::THEMES;
|
||||
use crate::{config, service, service_for_static_files, static_files, trace, LazyStatic};
|
||||
use crate::{config, service, service_for_static_files, static_files, trace};
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
use crate::db::*;
|
||||
|
||||
use std::sync::RwLock;
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
static_files!(base);
|
||||
|
||||
// PACKAGES ****************************************************************************************
|
||||
|
||||
static ENABLED_PACKAGES: LazyStatic<RwLock<Vec<PackageRef>>> =
|
||||
LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||
static ENABLED_PACKAGES: LazyLock<RwLock<Vec<PackageRef>>> =
|
||||
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||
|
||||
static DROPPED_PACKAGES: LazyStatic<RwLock<Vec<PackageRef>>> =
|
||||
LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||
static DROPPED_PACKAGES: LazyLock<RwLock<Vec<PackageRef>>> =
|
||||
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||
|
||||
// REGISTER PACKAGES *******************************************************************************
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
use crate::config;
|
||||
use crate::core::theme::ThemeRef;
|
||||
use crate::LazyStatic;
|
||||
|
||||
use std::sync::RwLock;
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
// THEMES ******************************************************************************************
|
||||
|
||||
pub static THEMES: LazyStatic<RwLock<Vec<ThemeRef>>> = LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||
pub static THEMES: LazyLock<RwLock<Vec<ThemeRef>>> = LazyLock::new(|| RwLock::new(Vec::new()));
|
||||
|
||||
// DEFAULT THEME ***********************************************************************************
|
||||
|
||||
pub static THEME_DEFAULT: LazyStatic<ThemeRef> =
|
||||
LazyStatic::new(|| match theme_by_short_name(&config::SETTINGS.app.theme) {
|
||||
pub static THEME_DEFAULT: LazyLock<ThemeRef> =
|
||||
LazyLock::new(|| match theme_by_short_name(&config::SETTINGS.app.theme) {
|
||||
Some(theme) => theme,
|
||||
None => &crate::base::theme::Inception,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use crate::core::component::{AnyComponent, AnyOp, MixedComponents};
|
||||
use crate::core::theme::ThemeRef;
|
||||
use crate::{fn_builder, AutoDefault, LazyStatic, TypeId};
|
||||
use crate::{fn_builder, AutoDefault, TypeId};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::RwLock;
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
static THEME_REGIONS: LazyStatic<RwLock<HashMap<TypeId, ComponentsInRegions>>> =
|
||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||
static THEME_REGIONS: LazyLock<RwLock<HashMap<TypeId, ComponentsInRegions>>> =
|
||||
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
static COMMON_REGIONS: LazyStatic<RwLock<ComponentsInRegions>> =
|
||||
LazyStatic::new(|| RwLock::new(ComponentsInRegions::default()));
|
||||
static COMMON_REGIONS: LazyLock<RwLock<ComponentsInRegions>> =
|
||||
LazyLock::new(|| RwLock::new(ComponentsInRegions::default()));
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct ComponentsInRegions(HashMap<&'static str, MixedComponents>);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue