Function bounded
fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>)
Creates a channel of bounded capacity.
This channel has a buffer that can hold at most cap messages at a time.
A special case is zero-capacity channel, which cannot hold any messages. Instead, send and receive operations must appear at the same time in order to pair up and pass the message over.
Examples
A channel of capacity 1:
use thread;
use Duration;
use bounded;
let = bounded;
// This call returns immediately because there is enough space in the channel.
s.send.unwrap;
spawn;
sleep;
assert_eq!;
assert_eq!;
A zero-capacity channel:
use thread;
use Duration;
use bounded;
let = bounded;
spawn;
sleep;
assert_eq!;