mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
feat(els): add Scheduler
This commit is contained in:
parent
20a94b806a
commit
67fefd196c
6 changed files with 250 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
use erg_common::config::ErgConfig;
|
||||
use erg_common::pathutil::NormalizedPathBuf;
|
||||
use erg_common::shared::MappedRwLockReadGuard;
|
||||
use erg_common::spawn::safe_yield;
|
||||
|
||||
use crate::context::{Context, ModuleContext};
|
||||
|
||||
|
@ -104,11 +105,23 @@ impl SharedCompilerResource {
|
|||
}
|
||||
}
|
||||
|
||||
/// This is intended to be called from a language server, etc.,
|
||||
/// this blocks until it gets a lock.
|
||||
pub fn remove_module(&self, path: &std::path::Path) -> Option<ModuleEntry> {
|
||||
if path.to_string_lossy().ends_with(".d.er") {
|
||||
self.py_mod_cache.remove(path)
|
||||
loop {
|
||||
if let Ok(entry) = self.py_mod_cache.try_remove(path) {
|
||||
return entry;
|
||||
}
|
||||
safe_yield();
|
||||
}
|
||||
} else {
|
||||
self.mod_cache.remove(path)
|
||||
loop {
|
||||
if let Ok(entry) = self.mod_cache.try_remove(path) {
|
||||
return entry;
|
||||
}
|
||||
safe_yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue