Skip to content

Commit 6748f78

Browse files
committed
Polymorphic protocols work well enough to do MapReduce.
I did some horrible things with type variable naming here. It should do the right thing in most cases, but we'll need to go through and make it correct someday.
1 parent 14adb98 commit 6748f78

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/libsyntax/ext/pipes/pipec.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,12 @@ impl compile of gen_init for protocol {
319319
}
320320

321321
fn buffer_ty_path(cx: ext_ctxt) -> @ast::ty {
322-
let mut params = ~[];
322+
let mut params: ~[ast::ty_param] = ~[];
323323
for (copy self.states).each |s| {
324324
for s.ty_params.each |tp| {
325-
if !params.contains(tp) {
326-
vec::push(params, tp);
325+
alt params.find(|tpp| *tp.ident == *tpp.ident) {
326+
none { vec::push(params, tp) }
327+
_ { }
327328
}
328329
}
329330
}
@@ -334,11 +335,12 @@ impl compile of gen_init for protocol {
334335

335336
fn gen_buffer_type(cx: ext_ctxt) -> @ast::item {
336337
let ext_cx = cx;
337-
let mut params = ~[];
338+
let mut params: ~[ast::ty_param] = ~[];
338339
let fields = do (copy self.states).map_to_vec |s| {
339340
for s.ty_params.each |tp| {
340-
if !params.contains(tp) {
341-
vec::push(params, tp);
341+
alt params.find(|tpp| *tp.ident == *tpp.ident) {
342+
none { vec::push(params, tp) }
343+
_ { }
342344
}
343345
}
344346
let ty = s.to_ty(cx);

src/test/bench/task-perf-word-count-generic.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,12 @@ mod map_reduce {
143143
proto! ctrl_proto {
144144
open: send<K: copy send, V: copy send> {
145145
find_reducer(K) -> reducer_response<K, V>,
146-
mapper_done -> terminated
146+
mapper_done -> !
147147
}
148148

149149
reducer_response: recv<K: copy send, V: copy send> {
150150
reducer(chan<reduce_proto<V>>) -> open<K, V>
151151
}
152-
153-
terminated: send { }
154152
}
155153

156154
enum reduce_proto<V: copy send> { emit_val(V), done, ref, release }
@@ -261,7 +259,7 @@ mod map_reduce {
261259
while num_mappers > 0 {
262260
let (_ready, message, ctrls) = pipes::select(ctrl);
263261
alt option::unwrap(message) {
264-
ctrl_proto::mapper_done(_) {
262+
ctrl_proto::mapper_done {
265263
// #error("received mapper terminated.");
266264
num_mappers -= 1;
267265
ctrl = ctrls;

0 commit comments

Comments
 (0)