Skip to content
Merged
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
10 changes: 10 additions & 0 deletions src/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ impl<T> Sender<T> {
Ok(self.poll_unparked(true))
}

/// Returns whether this channel is closed without needing a context.
pub fn is_closed(&self) -> bool {
!decode_state(self.inner.state.load(SeqCst)).is_open
}

fn poll_unparked(&mut self, do_park: bool) -> Async<()> {
// First check the `maybe_parked` variable. This avoids acquiring the
// lock in most cases
Expand Down Expand Up @@ -665,6 +670,11 @@ impl<T> Sink for Sender<T> {
}

impl<T> UnboundedSender<T> {
/// Returns whether this channel is closed without needing a context.
pub fn is_closed(&self) -> bool {
self.0.is_closed()
}

/// Sends the provided message along this channel.
///
/// This is an unbounded sender, so this function differs from `Sink::send`
Expand Down