Use recv when receiving messages and stop checking when the channel closes

This commit is contained in:
MinusGix 2022-07-31 21:01:13 -05:00
parent 28d049c975
commit 134267250e
1 changed files with 4 additions and 2 deletions

View File

@ -248,7 +248,7 @@ fn start_plugin(
let (tx, rx) = mpsc::channel();
thread::spawn(move || loop {
match rx.try_recv() {
match rx.recv() {
Ok(PluginTransmissionMessage::Initialize) => {
let initialize = local_plugin
.instance
@ -283,7 +283,9 @@ fn start_plugin(
}
break;
}
_ => {}
// There was an error when receiving, which means that the other end was closed.
// So we simply shutdown this thread by breaking out of the loop
Err(_) => break,
}
});
tx.send(PluginTransmissionMessage::Initialize)?;