Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't drop the subscribe for moq-clock. #147

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion moq-clock/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,14 @@ async fn run<S: webtransport_generic::Session>(session: S, config: cli::Config)
.context("failed to create MoQ Transport session")?;

let (prod, sub) = serve::Track::new(&config.namespace, &config.track).produce();
subscriber.subscribe(prod).context("failed to subscribe to track")?;
let subscribe = subscriber.subscribe(prod).context("failed to subscribe to track")?;

let clock = clock::Subscriber::new(sub);

tokio::select! {
res = session.run() => res.context("session error")?,
res = clock.run() => res.context("clock error")?,
res = subscribe.closed() => res.context("subscribe closed")?,
}
}

Expand Down
1 change: 1 addition & 0 deletions moq-transport/src/session/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl<S: webtransport_generic::Session> Drop for AnnounceState<S> {
}
}

#[must_use = "unannounce on drop"]
pub struct Announce<S: webtransport_generic::Session> {
publisher: Publisher<S>,
state: State<AnnounceState<S>>,
Expand Down
1 change: 1 addition & 0 deletions moq-transport/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::message::Message;
use crate::util::Queue;
use crate::{message, setup};

#[must_use = "run() must be called"]
pub struct Session<S: webtransport_generic::Session> {
webtransport: S,

Expand Down
1 change: 1 addition & 0 deletions moq-transport/src/session/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl Default for SubscribeState {
}

// Held by the application
#[must_use = "unsubscribe on drop"]
pub struct Subscribe<S: webtransport_generic::Session> {
state: State<SubscribeState>,
subscriber: Subscriber<S>,
Expand Down
1 change: 1 addition & 0 deletions moq-transport/src/session/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl<S: webtransport_generic::Session> Subscriber<S> {
self.announced_queue.pop().await
}

#[must_use = "unsubscribe on drop"]
pub fn subscribe(&mut self, track: serve::TrackWriter) -> Result<Subscribe<S>, ServeError> {
let id = self.subscribe_next.fetch_add(1, atomic::Ordering::Relaxed);

Expand Down
Loading