Skip to content

[IMP] server: improve reactivity of rebuilds on typing #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions server/src/core/odoo.rs
Original file line number Diff line number Diff line change
@@ -1421,15 +1421,7 @@ impl Odoo {

pub fn update_file_index(session: &mut SessionInfo, path: PathBuf, is_save: bool, is_open: bool, force_delay: bool) {
if path.extension().is_some() && path.extension().unwrap() == "py" {
if !force_delay && (is_open || (is_save && session.sync_odoo.config.refresh_mode == RefreshMode::OnSave)) {
let _ = SyncOdoo::_unload_path(session, &path, false);
Odoo::search_symbols_to_rebuild(session, &path.sanitize());
SyncOdoo::process_rebuilds(session);
} else {
if force_delay || session.sync_odoo.config.refresh_mode == RefreshMode::Adaptive {
SessionInfo::request_update_file_index(session, &path, force_delay);
}
}
SessionInfo::request_update_file_index(session, &path, is_save, force_delay);
}
}

1 change: 1 addition & 0 deletions server/src/server.rs
Original file line number Diff line number Diff line change
@@ -468,6 +468,7 @@ impl Server {
if DEBUG_THREADS {
info!("Sending notification to main thread : {}", n.method);
}
self.interrupt_rebuild_boolean.store(true, std::sync::atomic::Ordering::SeqCst);
self.sender_s_to_main.send(Message::Notification(n)).unwrap();
}
_ => {
32 changes: 27 additions & 5 deletions server/src/threads.rs
Original file line number Diff line number Diff line change
@@ -79,11 +79,33 @@ impl <'a> SessionInfo<'a> {
}
}

pub fn request_update_file_index(session: &mut SessionInfo, path: &PathBuf, forced_delay: bool) {
if !forced_delay && (session.delayed_process_sender.is_none() || !session.sync_odoo.need_rebuild && session.sync_odoo.config.refresh_mode == RefreshMode::Adaptive && session.sync_odoo.get_rebuild_queue_size() < 10) {
let _ = SyncOdoo::_unload_path(session, &path, false);
Odoo::search_symbols_to_rebuild(session, &path.sanitize());
SyncOdoo::process_rebuilds(session);
/*
* Request an update of the file in the index.
* path: path of the file
* process_now: indicate if the current action is due to a save action
* forced_delay: indicate that we want to force a delay
*/
pub fn request_update_file_index(session: &mut SessionInfo, path: &PathBuf, is_save: bool, forced_delay: bool) {
if (!forced_delay || session.delayed_process_sender.is_none()) && !session.sync_odoo.need_rebuild {
if session.sync_odoo.config.refresh_mode == RefreshMode::OnSave {
if is_save {
let _ = SyncOdoo::_unload_path(session, &path, false);
Odoo::search_symbols_to_rebuild(session, &path.sanitize());
SyncOdoo::process_rebuilds(session);
}
return;
}
if session.sync_odoo.config.refresh_mode == RefreshMode::Adaptive &&
session.sync_odoo.get_rebuild_queue_size() < 10 {
let _ = SyncOdoo::_unload_path(session, &path, false);
Odoo::search_symbols_to_rebuild(session, &path.sanitize());
SyncOdoo::process_rebuilds(session);
} else {
if forced_delay {
session.sync_odoo.watched_file_updates.store(session.sync_odoo.watched_file_updates.load(Ordering::SeqCst) + 1, Ordering::SeqCst);
}
let _ = session.delayed_process_sender.as_ref().unwrap().send(DelayedProcessingMessage::UPDATE_FILE_INDEX(UpdateFileIndexData { path: path.clone(), time: std::time::Instant::now(), forced_delay}));
}
} else {
if forced_delay {
session.sync_odoo.watched_file_updates.store(session.sync_odoo.watched_file_updates.load(Ordering::SeqCst) + 1, Ordering::SeqCst);