Closes the channel and notifies all blocked operations. Returns `true` if this call has closed the channel and it was not closed already.
(&self)
| 65 | /// |
| 66 | /// Returns `true` if this call has closed the channel and it was not closed already. |
| 67 | pub(super) fn close(&self) -> bool { |
| 68 | if self.queue.close() { |
| 69 | // Notify all send operations. |
| 70 | self.send_ops.notify(usize::MAX); |
| 71 | |
| 72 | // Notify all receive and stream operations. |
| 73 | self.recv_ops.notify(usize::MAX); |
| 74 | self.stream_ops.notify(usize::MAX); |
| 75 | |
| 76 | true |
| 77 | } else { |
| 78 | false |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | pub fn bounded<T>(cap: usize) -> Arc<Channel<T>> { |