Skip to content

Commit 531ea69

Browse files
committed
Remove shared_arc (unused) and fix trivial-message
1 parent 2d15b6e commit 531ea69

File tree

2 files changed

+2
-65
lines changed

2 files changed

+2
-65
lines changed

src/libcore/arc.rs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
* share immutable data between tasks.
44
*/
55

6-
import comm::{port, chan, methods};
76
import sys::methods;
87

9-
export arc, get, clone, shared_arc, get_arc;
8+
export arc, get, clone;
109

1110
export exclusive, methods;
1211

@@ -122,49 +121,6 @@ impl methods<T: send> for exclusive<T> {
122121
}
123122
}
124123

125-
// Convenience code for sharing arcs between tasks
126-
127-
type get_chan<T: const send> = chan<chan<arc<T>>>;
128-
129-
// (terminate, get)
130-
type shared_arc<T: const send> = (shared_arc_res, get_chan<T>);
131-
132-
class shared_arc_res {
133-
let c: comm::chan<()>;
134-
new(c: comm::chan<()>) { self.c = c; }
135-
drop { self.c.send(()); }
136-
}
137-
138-
fn shared_arc<T: send const>(-data: T) -> shared_arc<T> {
139-
let a = arc::arc(data);
140-
let p = port();
141-
let c = chan(p);
142-
do task::spawn() |move a| {
143-
let mut live = true;
144-
let terminate = port();
145-
let get = port();
146-
147-
c.send((chan(terminate), chan(get)));
148-
149-
while live {
150-
alt comm::select2(terminate, get) {
151-
either::left(()) { live = false; }
152-
either::right(cc) {
153-
comm::send(cc, arc::clone(&a));
154-
}
155-
}
156-
}
157-
};
158-
let (terminate, get) = p.recv();
159-
(shared_arc_res(terminate), get)
160-
}
161-
162-
fn get_arc<T: send const>(c: get_chan<T>) -> arc::arc<T> {
163-
let p = port();
164-
c.send(chan(p));
165-
p.recv()
166-
}
167-
168124
#[cfg(test)]
169125
mod tests {
170126
import comm::*;
@@ -196,25 +152,6 @@ mod tests {
196152
log(info, arc_v);
197153
}
198154

199-
#[test]
200-
fn auto_share_arc() {
201-
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
202-
let (_res, arc_c) = shared_arc(v);
203-
204-
let p = port();
205-
let c = chan(p);
206-
207-
do task::spawn() {
208-
let arc_v = get_arc(arc_c);
209-
let v = *get(&arc_v);
210-
assert v[2] == 3;
211-
212-
c.send(());
213-
};
214-
215-
assert p.recv() == ();
216-
}
217-
218155
#[test]
219156
#[ignore] // this can probably infinite loop too.
220157
fn exclusive_arc() {

src/test/run-pass/trivial-message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pipes::{port, chan}
1+
import pipes::{port, chan};
22

33
/*
44
This is about the simplest program that can successfully send a

0 commit comments

Comments
 (0)