➖ Sustituye parking_lot por std::sync

PageTop ya no lo necesita como dependencia directa: `std::sync` cubre
los bloqueos del contexto, los temas y las trazas. No se detecta pérdida
de rendimiento en ningún caso.

Usa `unwrap()` en los bloqueos, también en las extensiones, porque sus
secciones exclusivas no pueden provocar panic. Sólo pagetop-cron ignora
el envenenamiento, porque calcula fechas con el bloqueo tomado.
This commit is contained in:
Manuel Cillero 2026-11-09 07:22:18 +01:00
parent a6d15ab211
commit 698b917fb1
11 changed files with 31 additions and 56 deletions

View file

@ -11,10 +11,9 @@ use crate::response::read_flash_messages;
use crate::web::HttpRequest;
use crate::{CowStr, util};
use parking_lot::Mutex;
use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::sync::Mutex;
mod assets_op;
pub use assets_op::AssetsOp;

View file

@ -481,7 +481,7 @@ pub trait Contextual {
segments
};
let count = {
let mut map = self.context().id_counters.lock();
let mut map = self.context().id_counters.lock().unwrap();
let n = map.entry(TypeId::of::<C>()).or_insert(0);
*n += 1;
*n

View file

@ -1,9 +1,7 @@
use crate::core::theme::ThemeRef;
use crate::{global, trace};
use parking_lot::RwLock;
use std::sync::LazyLock;
use std::sync::{LazyLock, RwLock};
// **< TEMAS >**************************************************************************************
@ -11,7 +9,7 @@ static THEMES: LazyLock<RwLock<Vec<ThemeRef>>> = LazyLock::new(|| RwLock::new(Ve
// Registra el tema si no lo estaba ya, para evitar duplicados. Devuelve `true` si lo ha añadido.
pub(crate) fn register_theme(theme: ThemeRef) -> bool {
let mut themes = THEMES.write();
let mut themes = THEMES.write().unwrap();
if themes.iter().any(|t| t.type_id() == theme.type_id()) {
return false;
}
@ -21,7 +19,7 @@ pub(crate) fn register_theme(theme: ThemeRef) -> bool {
/// Devuelve los temas habilitados en la aplicación, en el orden en que se registraron.
pub fn enabled_themes() -> Vec<ThemeRef> {
THEMES.read().clone()
THEMES.read().unwrap().clone()
}
/// Devuelve el tema identificado por su [`short_name()`](crate::core::AnyInfo::short_name).
@ -30,6 +28,7 @@ pub fn enabled_themes() -> Vec<ThemeRef> {
pub fn theme_by_short_name(short_name: &str) -> Option<ThemeRef> {
THEMES
.read()
.unwrap()
.iter()
.find(|t| t.short_name().eq_ignore_ascii_case(short_name))
.copied()

View file

@ -2,10 +2,8 @@ use crate::core::component::{Child, ChildOp, Children, Component};
use crate::core::theme::{CoreRegions, RegionRef, ThemeRef};
use crate::{AutoDefault, UniqueId, builder_impl};
use parking_lot::RwLock;
use std::collections::HashMap;
use std::sync::{Arc, LazyLock};
use std::sync::{Arc, LazyLock, RwLock};
// Lista de prototipos de componentes por nombre de región.
//
@ -90,7 +88,7 @@ impl ChildrenInRegions {
let region_name = region.name();
// 1. Prototipos globales comunes.
if let Some(global_protos) = COMMON_REGIONS.read().get(region_name) {
if let Some(global_protos) = COMMON_REGIONS.read().unwrap().get(region_name) {
result.add_many(
global_protos
.iter()
@ -102,7 +100,7 @@ impl ChildrenInRegions {
result.add_many(page_children);
}
// 3. Prototipos del tema activo.
if let Some(theme_region) = THEME_REGIONS.read().get(&theme.type_id())
if let Some(theme_region) = THEME_REGIONS.read().unwrap().get(&theme.type_id())
&& let Some(theme_protos) = theme_region.get(region_name)
{
result.add_many(
@ -190,6 +188,7 @@ impl InRegion {
InRegion::ForTheme(theme, region) => {
THEME_REGIONS
.write()
.unwrap()
.entry(theme.type_id())
.or_default()
.push((*region).name(), proto);
@ -200,6 +199,6 @@ impl InRegion {
#[inline]
fn add_to_common(region: RegionRef, proto: Arc<dyn Component>) {
COMMON_REGIONS.write().push(region.name(), proto);
COMMON_REGIONS.write().unwrap().push(region.name(), proto);
}
}