aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-12 00:42:07 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-12 00:56:52 +0800
commitd5a039e9d882f8f50b3cc9cdc10bc7bd84a5fa4d (patch)
treec0ae87e58690685183e28925a4bc7b42188f2162 /mingling_core/src/program.rs
parent5f8bd86c982dbfb3d8ed47f84432a3347752157f (diff)
refactor(core): extract global resource store into standalone container
Refactor `GlobalResources` from a type-erased `Arc<Mutex<HashMap<...>>>` 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.
Diffstat (limited to 'mingling_core/src/program.rs')
-rw-r--r--mingling_core/src/program.rs10
1 files changed, 3 insertions, 7 deletions
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<ProgramHook<C>>,
- pub(crate) resources: GlobalResources,
+ pub(crate) resources: GlobalResContainer,
}
impl<C> Program<C>
@@ -124,7 +120,7 @@ where
hooks: Vec::new(),
- resources: Arc::new(Mutex::new(HashMap::new())),
+ resources: GlobalResContainer::new(),
}
}