Struct ksched::mpsc::Receiver [−][src]
pub struct Receiver<T>(_);
Expand description
The receiving end of a unbounded mpsc channel.
This value is created by the channel
function.
Implementations
impl<T> Receiver<T>
[src]
impl<T> Receiver<T>
[src]pub async fn recv(&mut self) -> Option<T>
[src]
pub async fn recv(&mut self) -> Option<T>
[src]Receives the next value for this receiver.
None
is returned when all Sender
halves have dropped, indicating
that no further values can be sent on the channel.
Examples
use ksched::sync::mpsc; use ksched::task; let (tx, mut rx) = mpsc::channel().unwrap(); task::spawn(async move { tx.send("hello").unwrap(); }); assert_eq!(Some("hello"), rx.recv().await); assert_eq!(None, rx.recv().await);
Values are buffered:
use ksched::sync::mpsc; let (tx, mut rx) = mpsc::channel().unwrap(); tx.send("hello").unwrap(); tx.send("world").unwrap(); assert_eq!(Some("hello"), rx.recv().await); assert_eq!(Some("world"), rx.recv().await);
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T> where
T: Send,
T: Send,
impl<T> Sync for Receiver<T> where
T: Send,
T: Send,