Skip to content

Commit

Permalink
restart engine on error
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Oct 15, 2023
1 parent 1f60af1 commit e3437d8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src-tauri/src/chess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,16 @@ pub async fn get_best_moves(
let key = (tab.clone(), engine.clone());

if state.engine_processes.contains_key(&key) {
let process = state.engine_processes.get_mut(&key).unwrap();
let mut process = process.lock().await;
process.stop().await?;
process.set_options(options.clone()).await?;
process.go(&go_mode).await?;
return Ok(());
{
let process = state.engine_processes.get_mut(&key).unwrap();
let mut process = process.lock().await;
if process.stop().await.is_ok() {
process.set_options(options.clone()).await?;
process.go(&go_mode).await?;
return Ok(());
}
}
state.engine_processes.remove(&key).unwrap();
}

let (mut process, mut reader) = EngineProcess::new(path)?;
Expand Down

0 comments on commit e3437d8

Please sign in to comment.