2010-06-23 23:03:09 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
use std;
|
2011-12-13 18:25:51 -06:00
|
|
|
import comm;
|
2012-08-15 16:10:46 -05:00
|
|
|
import comm::Chan;
|
2011-12-13 18:25:51 -06:00
|
|
|
import comm::chan;
|
|
|
|
import comm::send;
|
|
|
|
import comm::recv;
|
|
|
|
import task;
|
2011-08-13 17:20:11 -05:00
|
|
|
|
2011-04-19 15:35:49 -05:00
|
|
|
fn main() {
|
2011-08-25 13:20:43 -05:00
|
|
|
let p = comm::port();
|
2012-01-04 23:14:53 -06:00
|
|
|
let ch = comm::chan(p);
|
2012-06-30 18:19:07 -05:00
|
|
|
let t = task::spawn(|| child(ch) );
|
2011-08-25 13:20:43 -05:00
|
|
|
let y = recv(p);
|
2012-07-30 18:01:07 -05:00
|
|
|
error!{"received"};
|
2011-12-22 19:53:53 -06:00
|
|
|
log(error, y);
|
2011-07-27 07:19:39 -05:00
|
|
|
assert (y == 10);
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
|
|
|
|
2012-08-15 16:10:46 -05:00
|
|
|
fn child(c: Chan<int>) {
|
2012-07-30 18:01:07 -05:00
|
|
|
error!{"sending"};
|
2011-08-13 17:20:11 -05:00
|
|
|
send(c, 10);
|
2012-07-30 18:01:07 -05:00
|
|
|
error!{"value sent"};
|
2011-08-10 11:27:22 -05:00
|
|
|
}
|