diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-08-01 14:57:17 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-08-01 15:58:39 -0700 |
| commit | 939bca0d84af1b52539d7b02a3be03bd64fcc17d (patch) | |
| tree | 86e2bc7184d92002ad9dcb7c214af595be21a559 /src/lib | |
| parent | 6a6d5c669e363238abbed050f62658ee6e74cbbf (diff) | |
Added send and receive to comm library.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/comm.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/comm.rs b/src/lib/comm.rs index ad86e2a7a5f..1665626432a 100644 --- a/src/lib/comm.rs +++ b/src/lib/comm.rs @@ -1,4 +1,6 @@ import sys; +import ptr; +import unsafe; export _chan; export _port; @@ -6,16 +8,19 @@ export _port; export mk_port; native "rust" mod rustrt { + type void; type rust_chan; type rust_port; fn new_chan(po : *rust_port) -> *rust_chan; fn del_chan(ch : *rust_chan); fn drop_chan(ch : *rust_chan); + fn chan_send(ch: *rust_chan, v : *void); fn new_port(unit_sz : uint) -> *rust_port; fn del_port(po : *rust_port); fn drop_port(po : *rust_port); + fn port_recv(dp : *void, po : *rust_port); } resource chan_ptr(ch: *rustrt::rust_chan) { @@ -32,7 +37,8 @@ resource port_ptr(po: *rustrt::rust_port) { obj _chan[T](raw_chan : @chan_ptr) { fn send(v : &T) { - + rustrt::chan_send(**raw_chan, + unsafe::reinterpret_cast(ptr::addr_of(v))); } } @@ -42,7 +48,8 @@ obj _port[T](raw_port : @port_ptr) { } fn recv_into(v : &T) { - + rustrt::port_recv(unsafe::reinterpret_cast(ptr::addr_of(v)), + **raw_port); } } |
