mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
fix(els): minor bugs
This commit is contained in:
parent
f612340e80
commit
46610a1ae0
7 changed files with 55 additions and 18 deletions
|
@ -289,6 +289,19 @@ impl SharedModuleCache {
|
|||
ref_.get(path).map(|entry| &entry.module)
|
||||
}
|
||||
|
||||
pub fn raw_ref_ctx_with_timeout<Q: Eq + Hash + ?Sized>(
|
||||
&self,
|
||||
path: &Q,
|
||||
timeout: std::time::Duration,
|
||||
) -> Option<&ModuleContext>
|
||||
where
|
||||
NormalizedPathBuf: Borrow<Q>,
|
||||
{
|
||||
let _ref = self.0.try_borrow_for(timeout)?;
|
||||
let ref_ = unsafe { self.0.as_ptr().as_ref().unwrap() };
|
||||
ref_.get(path).map(|entry| &entry.module)
|
||||
}
|
||||
|
||||
// HACK: <builtins> is referenced very frequently and mutable references are not taken,
|
||||
// so it can be take without lock.
|
||||
pub fn raw_ref_builtins_ctx(&self) -> Option<&ModuleContext> {
|
||||
|
|
|
@ -142,11 +142,15 @@ impl SharedCompilerResource {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn raw_ref_ctx(&self, path: &std::path::Path) -> Option<&ModuleContext> {
|
||||
pub fn raw_ref_ctx_with_timeout(
|
||||
&self,
|
||||
path: &std::path::Path,
|
||||
timeout: std::time::Duration,
|
||||
) -> Option<&ModuleContext> {
|
||||
if path.to_string_lossy().ends_with(".d.er") {
|
||||
self.py_mod_cache.raw_ref_ctx(path)
|
||||
self.py_mod_cache.raw_ref_ctx_with_timeout(path, timeout)
|
||||
} else {
|
||||
self.mod_cache.raw_ref_ctx(path)
|
||||
self.mod_cache.raw_ref_ctx_with_timeout(path, timeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue