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.
This commit is contained in:
parent
14adb98b64
commit
6748f78cb1
2 changed files with 10 additions and 10 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue