Refactor FileCache to use Condvar for efficient waits
The `FileCache` now uses `std::sync::Condvar` to signal when files have finished loading. This replaces the previous spin-wait mechanism, significantly improving efficiency by allowing waiting threads to sleep until explicitly woken up. The `wait_for_load` method now blocks on the `Condvar`, and the `insert_m1` and `insert_tick` methods call `notify_all` after updating the cache and removing the loading guard. This ensures that all waiting threads are woken up and can re-check the cache. Additionally, `ensure_m1_loaded` and `ensure_tick_loaded` in `DataServer` have been simplified to directly call `wait_for_load` when another thread is already loading the file, removing the redundant synchronous loading logic. Refactor FileCache to use Condvar
This commit is contained in:
@@ -5,6 +5,7 @@ use myc::ast::parser::Parser;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
myc::ast::data_server::init_default_data_server();
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default().with_inner_size([1024.0, 768.0]),
|
||||
..Default::default()
|
||||
|
||||
Reference in New Issue
Block a user