Created
July 30, 2011 01:31
-
-
Save eholk/1115083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys; | |
| export _chan; | |
| export _port; | |
| export mk_port; | |
| native "rust" mod rustrt { | |
| 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 new_port(unit_sz : uint) -> *rust_port; | |
| fn del_port(po : *rust_port); | |
| fn drop_port(po : *rust_port); | |
| } | |
| resource chan_ptr(ch: *rustrt::rust_chan) { | |
| rustrt::drop_chan(ch); | |
| rustrt::drop_chan(ch); // FIXME: We shouldn't have to do this | |
| // twice. | |
| rustrt::del_chan(ch); | |
| } | |
| resource port_ptr(po: *rustrt::rust_port) { | |
| rustrt::drop_port(po); | |
| rustrt::del_port(po); | |
| } | |
| obj _chan[T](raw_chan : @chan_ptr) { | |
| } | |
| obj _port[T](raw_port : @port_ptr) { | |
| // fn mk_chan() -> _chan[T] { | |
| // _chan(@chan_ptr(rustrt::new_chan(**raw_port))) | |
| // } | |
| } | |
| fn mk_port() -> _port[T] { | |
| _chan(@port_ptr(rustrt::new_port(sys::size_of[T]()))) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment