diff options
| author | Eric Holk <eric.holk@gmail.com> | 2012-07-25 10:13:37 -0700 |
|---|---|---|
| committer | Eric Holk <eric.holk@gmail.com> | 2012-07-25 12:12:26 -0700 |
| commit | 6748f78cb1f360e2b151ed9eb3e487cf1c61ef0e (patch) | |
| tree | e610ab3c0aa2b6ffebd3b3495624aa51796eb56c /src | |
| parent | 14adb98b64d45c42c256d56e3f0fd167abd36434 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 14 | ||||
| -rw-r--r-- | src/test/bench/task-perf-word-count-generic.rs | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 529a5953dd5..392e6ba392a 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -319,11 +319,12 @@ impl compile of gen_init for protocol { } fn buffer_ty_path(cx: ext_ctxt) -> @ast::ty { - let mut params = ~[]; + let mut params: ~[ast::ty_param] = ~[]; for (copy self.states).each |s| { for s.ty_params.each |tp| { - if !params.contains(tp) { - vec::push(params, tp); + alt params.find(|tpp| *tp.ident == *tpp.ident) { + none { vec::push(params, tp) } + _ { } } } } @@ -334,11 +335,12 @@ impl compile of gen_init for protocol { fn gen_buffer_type(cx: ext_ctxt) -> @ast::item { let ext_cx = cx; - let mut params = ~[]; + let mut params: ~[ast::ty_param] = ~[]; let fields = do (copy self.states).map_to_vec |s| { for s.ty_params.each |tp| { - if !params.contains(tp) { - vec::push(params, tp); + alt params.find(|tpp| *tp.ident == *tpp.ident) { + none { vec::push(params, tp) } + _ { } } } let ty = s.to_ty(cx); diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 62aa4d75f20..47bb538d03d 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -143,14 +143,12 @@ mod map_reduce { proto! ctrl_proto { open: send<K: copy send, V: copy send> { find_reducer(K) -> reducer_response<K, V>, - mapper_done -> terminated + mapper_done -> ! } reducer_response: recv<K: copy send, V: copy send> { reducer(chan<reduce_proto<V>>) -> open<K, V> } - - terminated: send { } } enum reduce_proto<V: copy send> { emit_val(V), done, ref, release } @@ -261,7 +259,7 @@ mod map_reduce { while num_mappers > 0 { let (_ready, message, ctrls) = pipes::select(ctrl); alt option::unwrap(message) { - ctrl_proto::mapper_done(_) { + ctrl_proto::mapper_done { // #error("received mapper terminated."); num_mappers -= 1; ctrl = ctrls; |
