make SessionGroup::await_stale_sessions Send

This commit is contained in:
Scott Lamb 2021-12-29 20:32:03 -08:00
parent bcc885474b
commit 9a519c8e25

View File

@ -184,14 +184,15 @@ impl SessionGroup {
pub async fn await_stale_sessions(&self, status: &StaleSessionStatus) { pub async fn await_stale_sessions(&self, status: &StaleSessionStatus) {
loop { loop {
let notified = self.notify.notified(); let notified = self.notify.notified();
let l = self.sessions.lock().unwrap(); {
let all_gone = l let l = self.sessions.lock().unwrap();
.sessions let all_gone = l
.iter() .sessions
.all(|s| !s.maybe_playing || s.seqnum >= status.next_seqnum); .iter()
drop(l); .all(|s| !s.maybe_playing || s.seqnum >= status.next_seqnum);
if all_gone { if all_gone {
return; return;
}
} }
notified.await; notified.await;
} }
@ -2158,4 +2159,13 @@ mod tests {
assert!(!has_live555_tcp_bug("LIVE555 Streaming Media v2017.06.04")); assert!(!has_live555_tcp_bug("LIVE555 Streaming Media v2017.06.04"));
assert!(!has_live555_tcp_bug("LIVE555 Streaming Media v2020.01.01")); assert!(!has_live555_tcp_bug("LIVE555 Streaming Media v2020.01.01"));
} }
#[test]
fn await_stale_sessions_is_send() {
// There's probably a more elegant way to test this, but here goes.
fn assert_send<T: Send>(_: T) {}
let group = SessionGroup::default();
let stale_sessions = group.stale_sessions();
assert_send(group.await_stale_sessions(&stale_sessions));
}
} }