mirror of
https://github.com/fafhrd91/actix-net
synced 2025-02-07 13:34:24 +01:00
Add oneshot::Sender::is_canceled() method
This commit is contained in:
parent
b28f32e82c
commit
52ecb4bcc5
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
* Allow to create `framed::Dispatcher` with custom `mpsc::Receiver`
|
* Allow to create `framed::Dispatcher` with custom `mpsc::Receiver`
|
||||||
|
|
||||||
|
* Add `oneshot::Sender::is_canceled()` method
|
||||||
|
|
||||||
## [1.0.1] - 2019-12-11
|
## [1.0.1] - 2019-12-11
|
||||||
|
|
||||||
* Optimize InOrder service
|
* Optimize InOrder service
|
||||||
|
@ -67,6 +67,12 @@ impl<T> Sender<T> {
|
|||||||
Err(val)
|
Err(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tests to see whether this `Sender`'s corresponding `Receiver`
|
||||||
|
/// has gone away.
|
||||||
|
pub fn is_canceled(&self) -> bool {
|
||||||
|
self.inner.strong_count() == 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Drop for Sender<T> {
|
impl<T> Drop for Sender<T> {
|
||||||
@ -110,7 +116,9 @@ mod tests {
|
|||||||
assert_eq!(rx.await.unwrap(), "test");
|
assert_eq!(rx.await.unwrap(), "test");
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
assert!(!tx.is_canceled());
|
||||||
drop(rx);
|
drop(rx);
|
||||||
|
assert!(tx.is_canceled());
|
||||||
assert!(tx.send("test").is_err());
|
assert!(tx.send("test").is_err());
|
||||||
|
|
||||||
let (tx, rx) = channel::<&'static str>();
|
let (tx, rx) = channel::<&'static str>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user