Explain WASAPI self-join handling and shared event lifetime

This commit is contained in:
fufesou 2026-09-13 10:30:12 +08:00
parent b8ad274267
commit 0bf4a78ec5

View file

@ -177,6 +177,9 @@ impl Drop for Stream {
fn drop(&mut self) { fn drop(&mut self) {
let _ = self.push_command(Command::Terminate); let _ = self.push_command(Command::Terminate);
if let Some(thread) = self.thread.take() { if let Some(thread) = self.thread.take() {
// Prevent self-join: Terminate was sent; the thread exits after the current callback
// returns. Shared event ownership keeps the handle alive until both Stream and
// RunContext release it.
if thread.thread().id() != thread::current().id() { if thread.thread().id() != thread::current().id() {
let _ = thread.join(); let _ = thread.join();
} }