Skip to content

Commit

Permalink
wrap parse_module_cache in an Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaBatty committed Jan 17, 2024
1 parent 0f751fa commit fe93ba1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sway-core/src/query_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ pub type ProgramsCacheMap = HashMap<ModulePath, ProgramsCacheEntry>;

#[derive(Debug, Default)]
pub struct QueryEngine {
parse_module_cache: RwLock<ModuleCacheMap>,
parse_module_cache: Arc<RwLock<ModuleCacheMap>>,
programs_cache: Arc<RwLock<ProgramsCacheMap>>,
}

impl Clone for QueryEngine {
fn clone(&self) -> Self {
Self {
parse_module_cache: RwLock::new(self.parse_module_cache.read().unwrap().clone()),
parse_module_cache: self.parse_module_cache.clone(),
programs_cache: self.programs_cache.clone(),
}
}
Expand All @@ -67,11 +67,10 @@ impl QueryEngine {
}

pub fn insert_parse_module_cache_entry(&self, entry: ModuleCacheEntry) {
let mut cache = self.parse_module_cache.write().unwrap();
let path = entry.path.clone();
let include_tests = entry.include_tests;

let key = ModuleCacheKey::new(path, include_tests);
let mut cache = self.parse_module_cache.write().unwrap();
cache.insert(key, entry);
}

Expand Down

0 comments on commit fe93ba1

Please sign in to comment.