From 531ea695f64e8d7105f904c515a6ff84fa32dc77 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 25 Jul 2012 14:33:18 -0700 Subject: [PATCH] Remove shared_arc (unused) and fix trivial-message --- src/libcore/arc.rs | 65 +--------------------------- src/test/run-pass/trivial-message.rs | 2 +- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/libcore/arc.rs b/src/libcore/arc.rs index 28f072644105..9c46df9731b9 100644 --- a/src/libcore/arc.rs +++ b/src/libcore/arc.rs @@ -3,10 +3,9 @@ * share immutable data between tasks. */ -import comm::{port, chan, methods}; import sys::methods; -export arc, get, clone, shared_arc, get_arc; +export arc, get, clone; export exclusive, methods; @@ -122,49 +121,6 @@ impl methods for exclusive { } } -// Convenience code for sharing arcs between tasks - -type get_chan = chan>>; - -// (terminate, get) -type shared_arc = (shared_arc_res, get_chan); - -class shared_arc_res { - let c: comm::chan<()>; - new(c: comm::chan<()>) { self.c = c; } - drop { self.c.send(()); } -} - -fn shared_arc(-data: T) -> shared_arc { - let a = arc::arc(data); - let p = port(); - let c = chan(p); - do task::spawn() |move a| { - let mut live = true; - let terminate = port(); - let get = port(); - - c.send((chan(terminate), chan(get))); - - while live { - alt comm::select2(terminate, get) { - either::left(()) { live = false; } - either::right(cc) { - comm::send(cc, arc::clone(&a)); - } - } - } - }; - let (terminate, get) = p.recv(); - (shared_arc_res(terminate), get) -} - -fn get_arc(c: get_chan) -> arc::arc { - let p = port(); - c.send(chan(p)); - p.recv() -} - #[cfg(test)] mod tests { import comm::*; @@ -196,25 +152,6 @@ mod tests { log(info, arc_v); } - #[test] - fn auto_share_arc() { - let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - let (_res, arc_c) = shared_arc(v); - - let p = port(); - let c = chan(p); - - do task::spawn() { - let arc_v = get_arc(arc_c); - let v = *get(&arc_v); - assert v[2] == 3; - - c.send(()); - }; - - assert p.recv() == (); - } - #[test] #[ignore] // this can probably infinite loop too. fn exclusive_arc() { diff --git a/src/test/run-pass/trivial-message.rs b/src/test/run-pass/trivial-message.rs index 8e92e8f2020f..ab3efd6b22ea 100644 --- a/src/test/run-pass/trivial-message.rs +++ b/src/test/run-pass/trivial-message.rs @@ -1,4 +1,4 @@ -import pipes::{port, chan} +import pipes::{port, chan}; /* This is about the simplest program that can successfully send a