Skip to content

Commit

Permalink
Add subscribe method to broadcast::Receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Simmons committed Apr 8, 2022
1 parent 83477c7 commit a808310
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tokio/src/sync/broadcast.rs
Expand Up @@ -758,6 +758,13 @@ impl<T> Receiver<T> {
self.len() == 0
}

/// Creates a new [`Receiver`] handle that will receive values sent **after**
/// this call to `subscribe`.
pub fn subscribe(&self) -> Self {
let shared = self.shared.clone();
new_receiver(shared)
}

/// Locks the next value if there is one.
fn recv_ref(
&mut self,
Expand Down

0 comments on commit a808310

Please sign in to comment.