Skip to content
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

Long running filewatcher is dropped #58

Open
codyduong opened this issue Dec 31, 2024 · 0 comments
Open

Long running filewatcher is dropped #58

codyduong opened this issue Dec 31, 2024 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers priority high
Milestone

Comments

@codyduong
Copy link
Owner

This tx is eventually dropped, I'm not entirely sure why. We should in general restructure this.

{
let sender = sender.clone();
let _filewatcher_handle = thread::spawn(move || {
loop {
match rx.recv() {
Ok(event) => match event {
Ok(e) => {
log::info!("File update: {:?}", e);
sender.input(AppMsg::DestroyActual);
if !is_stopped.load(Ordering::SeqCst) {
// if we are stuck in lua execution loop we need to dispatch a response to it for it to implode itself
let mut wg = CONFIG_UPDATE.write();
*wg = true;
drop(wg);
match rx_lua.recv() {
Ok(true) => {
log::info!("Lua thread reset itself within lua environment");
}
Ok(false) => {
log::info!("Lua thread coroutine deadlocked, starting new lua thread");
runtime.clone().start_runtime();
}
Err(_) => {
// @codyduong LOL, todo
log::error!("Lua channel closed before receiving confirmation of launch of lua thread");
is_stopped.store(true, Ordering::SeqCst);
}
}
} else {
log::info!("Lua thread finished executing, starting new lua thread");
// otherwise we have finished execution, so dispatch a new thread
runtime.clone().start_runtime();
is_stopped.store(false, Ordering::SeqCst);
}
}
Err(e) => {
log::error!("Watch error: {:?}", e);
}
},
Err(e) => {
log::error!("Receive error: {:?}", e);
break;
}
};
thread::sleep(Duration::from_millis(100));
}
});
}

@codyduong codyduong added bug Something isn't working good first issue Good for newcomers priority high labels Dec 31, 2024
@codyduong codyduong added this to the 0.1.0 milestone Dec 31, 2024
@codyduong codyduong self-assigned this Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers priority high
Projects
None yet
Development

No branches or pull requests

1 participant