clone component configs
This commit is contained in:
parent
4e3b349e20
commit
7c772e0d48
1 changed files with 4 additions and 3 deletions
|
@ -77,7 +77,7 @@ impl ComponentConfigs {
|
|||
self.map.get(&type_id).cloned().map(|handle| {
|
||||
let (cfg, generation) = handle.read::<T>().unwrap();
|
||||
ComponentConfig {
|
||||
cfg,
|
||||
cfg: Arc::new(cfg),
|
||||
generation,
|
||||
handle,
|
||||
}
|
||||
|
@ -85,8 +85,9 @@ impl ComponentConfigs {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ComponentConfig<T> {
|
||||
cfg: T,
|
||||
cfg: Arc<T>,
|
||||
generation: usize,
|
||||
handle: Arc<ConfigHandle>,
|
||||
}
|
||||
|
@ -121,7 +122,7 @@ impl<T: IsComponentConfig> ComponentConfig<T> {
|
|||
pub fn force_update(&mut self) -> T {
|
||||
let (cfg, generation) = self.handle.read::<T>().unwrap();
|
||||
self.generation = generation;
|
||||
mem::replace(&mut self.cfg, cfg)
|
||||
mem::replace(Arc::make_mut(&mut self.cfg), cfg)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue