Closed simao closed 10 years ago
It is, but you have to use std::com::SharedChan;
or use it like let chan = comm::SharedChan::new(chan);
.
Tutorial will need fixing of course.
Ah thanks, that works!
Just checked the markdown source for the tutorial and it includes:
# use std::task::spawn;
# use std::comm::{stream, SharedChan};
But that's not rendered on the html version.
On Fri, Sep 27, 2013 at 8:33 PM, Jack Moffitt notifications@github.comwrote:
It is, but you have to use std::com::SharedChan; or use it like let chan = comm::SharedChan::new(chan);.
Tutorial will need fixing of course.
— Reply to this email directly or view it on GitHubhttps://github.com/mozilla/rust/issues/9573#issuecomment-25271015 .
This can be closed, the following code is from the tutorial and works as expected (without explicit imports):
fn main() {
// single sender and receiver
let (port, chan): (Port<int>, Chan<int>) = Chan::new();
do spawn {
chan.send(5);
}
println!("{:d}", port.recv());
// multiple senders
let (port, chan) = SharedChan::new();
for i in range(0, 3) {
let child_chan = chan.clone();
do spawn {
child_chan.send(i);
}
}
println!("{:d} {:d} {:d}", port.recv(), port.recv(), port.recv());
}
Hello,
I am reading the Rust Tasks and Communication Tutorial and I am trying to run the following code:
I thought
SharedChan
was defined instd::comm
?Thanks