Struct rustfbp::component::OptionReceiver
[−]
[src]
pub struct OptionReceiver<T> { // some fields omitted }
Represent the default options simple input port
It is different from a classical Receiver because it :
Remember the last message received
If there is more than one message inside the channel, it keeps only the last one.
If there is no message in the channel, it sends the last one. If it is the first message, it block until there is a message
Example
let (s, r) = sync_channel(16); let or = OptionReceiver::new(r); s.send(23).unwrap(); assert_eq!(or.recv().unwrap(), 23); assert_eq!(or.recv().unwrap(), 23); s.send(42).unwrap(); s.send(666).unwrap(); assert_eq!(or.recv().unwrap(), 666);