| 118 | |
| 119 | impl<T> Sender<T> { |
| 120 | pub fn try_send(&self, msg: T) -> Result<(), TrySendError<T>> { |
| 121 | match self.channel.queue.push(msg) { |
| 122 | Ok(()) => { |
| 123 | // Notify a single blocked receive operation. If the notified operation then |
| 124 | // receives a message or gets canceled, it will notify another blocked receive |
| 125 | // operation. |
| 126 | self.channel.recv_ops.notify(1); |
| 127 | |
| 128 | // Notify all blocked streams. |
| 129 | self.channel.stream_ops.notify(usize::MAX); |
| 130 | |
| 131 | Ok(()) |
| 132 | } |
| 133 | Err(PushError::Full(msg)) => Err(TrySendError::Full(msg)), |
| 134 | Err(PushError::Closed(msg)) => Err(TrySendError::Closed(msg)), |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | pub async fn send(&self, msg: T) -> Result<(), SendError<T>> { |
| 139 | let mut listener = None; |