File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -600,6 +600,11 @@ impl<T> Sender<T> {
600600 Ok ( self . poll_unparked ( true ) )
601601 }
602602
603+ /// Returns whether this channel is closed without needing a context.
604+ pub fn is_closed ( & self ) -> bool {
605+ !decode_state ( self . inner . state . load ( SeqCst ) ) . is_open
606+ }
607+
603608 fn poll_unparked ( & mut self , do_park : bool ) -> Async < ( ) > {
604609 // First check the `maybe_parked` variable. This avoids acquiring the
605610 // lock in most cases
@@ -665,6 +670,11 @@ impl<T> Sink for Sender<T> {
665670}
666671
667672impl < T > UnboundedSender < T > {
673+ /// Returns whether this channel is closed without needing a context.
674+ pub fn is_closed ( & self ) -> bool {
675+ self . 0 . is_closed ( )
676+ }
677+
668678 /// Sends the provided message along this channel.
669679 ///
670680 /// This is an unbounded sender, so this function differs from `Sink::send`
You can’t perform that action at this time.
0 commit comments