about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-29 18:52:16 -0700
committerEric Holk <eholk@mozilla.com>2011-08-01 15:58:30 -0700
commitb3d9d9b73cb9cae6b76e0a040756784112ed88a9 (patch)
treef28ccfdb78e36fdec04781da31ddb6d207b2410e /src
parent5a673cc2c9d1a85efb967c47e40cb805ba691b90 (diff)
downloadrust-b3d9d9b73cb9cae6b76e0a040756784112ed88a9.tar.gz
rust-b3d9d9b73cb9cae6b76e0a040756784112ed88a9.zip
Objectified library chans and ports.
Diffstat (limited to 'src')
-rw-r--r--src/lib/comm.rs25
-rw-r--r--src/rt/rust_builtin.cpp1
-rw-r--r--src/test/stdtest/comm.rs2
3 files changed, 15 insertions, 13 deletions
diff --git a/src/lib/comm.rs b/src/lib/comm.rs
index 7fcac262a5c..ad86e2a7a5f 100644
--- a/src/lib/comm.rs
+++ b/src/lib/comm.rs
@@ -4,7 +4,6 @@ export _chan;
 export _port;
 
 export mk_port;
-export mk_chan;
 
 native "rust" mod rustrt {
     type rust_chan;
@@ -26,23 +25,27 @@ resource chan_ptr(ch: *rustrt::rust_chan) {
     rustrt::del_chan(ch);
 }
 
-tag _chan[T] { _chan(@chan_dtor); }
-
 resource port_ptr(po: *rustrt::rust_port) {
     rustrt::drop_port(po);
     rustrt::del_port(po);
 }
 
-tag _port[T] { _port(@port_dtor); }
+obj _chan[T](raw_chan : @chan_ptr) {
+    fn send(v : &T) {
 
-fn mk_port[T]() -> _port[T] {
-    _port(@port_dtor(rustrt::new_port(sys::size_of[T]())))
+    }
 }
 
-fn mk_chan[T](po : &_port[T]) -> _chan[T] {
-    alt po {
-      _port(_po) {
-        _chan(@chan_dtor(rustrt::new_chan(**_po)))
-      }
+obj _port[T](raw_port : @port_ptr) {
+    fn mk_chan() -> _chan[T] {
+        _chan(@chan_ptr(rustrt::new_chan(**raw_port)))
     }
+
+    fn recv_into(v : &T) {
+
+    }
+}
+
+fn mk_port[T]() -> _port[T] {
+    _port(@port_ptr(rustrt::new_port(sys::size_of[T]())))
 }
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 143a0b22f73..989e0a4800a 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -912,7 +912,6 @@ void drop_chan(rust_task *task, rust_chan *chan) {
 extern "C" CDECL
 void drop_port(rust_task *, rust_port *port) {
     port->ref_count--;
->>>>>>> Started working on a library-based comm system. Creating and deleting ports work.
 }
 
 //
diff --git a/src/test/stdtest/comm.rs b/src/test/stdtest/comm.rs
index 040593be9ba..27568f53c79 100644
--- a/src/test/stdtest/comm.rs
+++ b/src/test/stdtest/comm.rs
@@ -4,5 +4,5 @@ import std::comm;
 #[test]
 fn create_port_and_chan() {
     let p = comm::mk_port[int]();
-    let c = comm::mk_chan(p);
+    let c = p.mk_chan();
 }