From d5a039e9d882f8f50b3cc9cdc10bc7bd84a5fa4d Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 12 Aug 2026 00:42:07 +0800 Subject: refactor(core): extract global resource store into standalone container Refactor `GlobalResources` from a type-erased `Arc>>` alias into a `GlobalResContainer` struct with per-resource mutexes. This prevents nested `modify_res` calls from deadlocking, allows independent containers to coexist, and keeps `Program`'s public resource API unchanged. --- mingling_core/src/program.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'mingling_core/src/program.rs') diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs index 3c43cee..be8d85c 100644 --- a/mingling_core/src/program.rs +++ b/mingling_core/src/program.rs @@ -2,13 +2,9 @@ use std::env; use crate::{ - AnyOutput, GlobalResources, asset::dispatcher::Dispatcher, error::ChainProcessError, + AnyOutput, GlobalResContainer, asset::dispatcher::Dispatcher, error::ChainProcessError, hook::ProgramHook, }; -use std::{ - collections::HashMap, - sync::{Arc, Mutex}, -}; #[doc(hidden)] pub mod error; @@ -81,7 +77,7 @@ where pub(crate) hooks: Vec>, - pub(crate) resources: GlobalResources, + pub(crate) resources: GlobalResContainer, } impl Program @@ -124,7 +120,7 @@ where hooks: Vec::new(), - resources: Arc::new(Mutex::new(HashMap::new())), + resources: GlobalResContainer::new(), } } -- cgit