Skip to content

Commit b321312

Browse files
nikomatsakisbrson
authored andcommitted
---
yaml --- r: 5930 b: refs/heads/master c: d9b23cb h: refs/heads/master v: v3
1 parent 382b3a0 commit b321312

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 44697a4293ae083e57b49cc2afe6cf7fca71b10a
2+
refs/heads/master: d9b23cb0224efb7157d2888bdaef85edebf6dd08

trunk/src/lib/comm.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ export recv;
88
export chan;
99
export port;
1010

11-
native "rust" mod rustrt {
11+
native "c-stack-cdecl" mod rustrt {
1212
type void;
1313
type rust_port;
1414

15-
fn chan_id_send<~T>(target_task: task::task, target_port: port_id,
15+
fn chan_id_send<~T>(unused_task: *void, t: *sys::type_desc,
16+
target_task: task::task, target_port: port_id,
1617
-data: T);
1718

18-
fn new_port(unit_sz: uint) -> *rust_port;
19-
fn del_port(po: *rust_port);
20-
fn drop_port(po: *rust_port);
21-
fn get_port_id(po: *rust_port) -> port_id;
19+
fn new_port(unused_task: *void, unit_sz: uint) -> *rust_port;
20+
fn del_port(unused_task: *void, po: *rust_port);
21+
fn drop_port(unused_task: *void, po: *rust_port);
22+
fn get_port_id(unused_task: *void, po: *rust_port) -> port_id;
2223
}
2324

2425
native "rust-intrinsic" mod rusti {
@@ -32,23 +33,28 @@ type port_id = int;
3233
tag chan<~T> { chan_t(task::task, port_id); }
3334

3435
resource port_ptr(po: *rustrt::rust_port) {
35-
rustrt::drop_port(po);
36-
rustrt::del_port(po);
36+
rustrt::drop_port(ptr::null(), po);
37+
rustrt::del_port(ptr::null(), po);
3738
}
3839

3940
tag port<~T> { port_t(@port_ptr); }
4041

4142
fn send<~T>(ch: chan<T>, -data: T) {
4243
let chan_t(t, p) = ch;
43-
rustrt::chan_id_send(t, p, data);
44+
rustrt::chan_id_send(ptr::null(), sys::get_type_desc::<T>(), t, p, data);
45+
task::yield();
4446
}
4547

4648
fn port<~T>() -> port<T> {
47-
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>())))
49+
let p = rustrt::new_port(ptr::null(), sys::size_of::<T>());
50+
ret port_t(@port_ptr(p));
4851
}
4952

50-
fn recv<~T>(p: port<T>) -> T { ret rusti::recv(***p) }
53+
fn recv<~T>(p: port<T>) -> T {
54+
ret rusti::recv(***p);
55+
}
5156

5257
fn chan<~T>(p: port<T>) -> chan<T> {
53-
chan_t(task::get_task_id(), rustrt::get_port_id(***p))
58+
let id = rustrt::get_port_id(ptr::null(), ***p);
59+
ret chan_t(task::get_task_id(), id);
5460
}

trunk/src/rt/rust_builtin.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ chan_id_send(type_desc *t, rust_task_id target_task_id,
576576
port->remote_chan->send(sptr);
577577
}
578578
target_task->deref();
579-
task->yield();
580579
}
581580
}
582581

trunk/src/test/stdtest/comm.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import std::comm;
44
#[test]
55
fn create_port_and_chan() { let p = comm::port::<int>(); comm::chan(p); }
66

7+
#[test]
8+
fn send_int() {
9+
let p = comm::port::<int>();
10+
let c = comm::chan(p);
11+
comm::send(c, 22);
12+
}
13+
714
#[test]
815
fn send_recv_fn() {
916
let p = comm::port::<int>();
@@ -21,9 +28,17 @@ fn send_recv_fn_infer() {
2128
}
2229

2330
#[test]
24-
fn chan_chan() {
31+
fn chan_chan_infer() {
2532
let p = comm::port(), p2 = comm::port::<int>();
2633
let c = comm::chan(p);
2734
comm::send(c, comm::chan(p2));
2835
comm::recv(p);
2936
}
37+
38+
#[test]
39+
fn chan_chan() {
40+
let p = comm::port::<comm::chan<int>>(), p2 = comm::port::<int>();
41+
let c = comm::chan(p);
42+
comm::send(c, comm::chan(p2));
43+
comm::recv(p);
44+
}

0 commit comments

Comments
 (0)