Linux/Unix requires that processes be waited, which is unfortunate as Windows lets us abandon them to the murderous whims of the OS. This PR adds Unix-specific behaviour to send a SIGINT before waiting on the process, and adds an additional thread per call for asset disposal on all platforms. Closes #38. --- * Close processes by SIGINT and wait on Unix This seems to remedy the Linux-specific zombie processes. Addition of nix as a dependency *should* be fine on Windows, since I believe it compiles to an empty crate. * Dispose of Tracks on auxiliary thread This adds a mechanism for the mixer threads to perform potentially expensive deallocation/cleanup outside of the main loop, preventing deadline misses etc. This should make misbehaving `wait`s a bit more friendly.
53 lines
1.1 KiB
Rust
53 lines
1.1 KiB
Rust
#![allow(missing_docs)]
|
|
|
|
mod core;
|
|
mod disposal;
|
|
mod events;
|
|
mod mixer;
|
|
mod udp_rx;
|
|
mod udp_tx;
|
|
mod ws;
|
|
|
|
pub use self::{core::*, disposal::*, events::*, mixer::*, udp_rx::*, udp_tx::*, ws::*};
|
|
|
|
use flume::Sender;
|
|
use tracing::info;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Interconnect {
|
|
pub core: Sender<CoreMessage>,
|
|
pub events: Sender<EventMessage>,
|
|
pub mixer: Sender<MixerMessage>,
|
|
}
|
|
|
|
impl Interconnect {
|
|
pub fn poison(&self) {
|
|
let _ = self.events.send(EventMessage::Poison);
|
|
}
|
|
|
|
pub fn poison_all(&self) {
|
|
let _ = self.mixer.send(MixerMessage::Poison);
|
|
self.poison();
|
|
}
|
|
|
|
pub fn restart_volatile_internals(&mut self) {
|
|
self.poison();
|
|
|
|
let (evt_tx, evt_rx) = flume::unbounded();
|
|
|
|
self.events = evt_tx;
|
|
|
|
let ic = self.clone();
|
|
tokio::spawn(async move {
|
|
info!("Event processor restarted.");
|
|
super::events::runner(ic, evt_rx).await;
|
|
info!("Event processor finished.");
|
|
});
|
|
|
|
// Make mixer aware of new targets...
|
|
let _ = self
|
|
.mixer
|
|
.send(MixerMessage::ReplaceInterconnect(self.clone()));
|
|
}
|
|
}
|