terminate worker thread as soon as possible to avoid race conditions
This commit is contained in:
@@ -143,6 +143,12 @@ impl futures::Future for Worker {
|
|||||||
loop {
|
loop {
|
||||||
let mut progress = false;
|
let mut progress = false;
|
||||||
|
|
||||||
|
if self.session.is_invalid() {
|
||||||
|
self.player.stop();
|
||||||
|
self.events.send(Event::Player(PlayerEvent::Stopped));
|
||||||
|
return Poll::Ready(Result::Err(()));
|
||||||
|
}
|
||||||
|
|
||||||
if let Poll::Ready(Some(cmd)) = self.commands.as_mut().poll_next(cx) {
|
if let Poll::Ready(Some(cmd)) = self.commands.as_mut().poll_next(cx) {
|
||||||
progress = true;
|
progress = true;
|
||||||
debug!("message received!");
|
debug!("message received!");
|
||||||
@@ -216,11 +222,6 @@ impl futures::Future for Worker {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.session.is_invalid() {
|
|
||||||
self.events.send(Event::Player(PlayerEvent::Stopped));
|
|
||||||
return Poll::Ready(Result::Err(()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if !progress {
|
if !progress {
|
||||||
return Poll::Pending;
|
return Poll::Pending;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user