MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / try_send

Method try_send

flow-rs/src/channel/inner.rs:120–136  ·  view source on GitHub ↗
(&self, msg: T)

Source from the content-addressed store, hash-verified

118
119impl<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;

Callers 2

sendMethod · 0.80
buildMethod · 0.80

Calls 2

pushMethod · 0.80
notifyMethod · 0.80

Tested by

no test coverage detected