core: patch from nmatsakis to make futures non-copyable

This commit is contained in:
Jeff Olson 2012-08-28 21:28:25 -07:00 committed by Brian Anderson
parent 27129c6aba
commit 02ddbadc10
2 changed files with 8 additions and 4 deletions

View file

@ -33,7 +33,11 @@ export future_pipe;
#[doc = "The future type"]
struct Future<A> {
/*priv*/ mut state: FutureState<A>,
/*priv*/ mut state: FutureState<A>;
// FIXME(#2829) -- futures should not be copyable, because they close
// over fn~'s that have pipes and so forth within!
drop {}
}
priv enum FutureState<A> {
@ -88,7 +92,7 @@ fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
port_ <-> *port;
let port = option::unwrap(port_);
match recv(port) {
future_pipe::completed(move data) => data
future_pipe::completed(move data) => data
}
}
}

View file

@ -415,13 +415,13 @@ mod tests {
for uint::range(0u, num_tasks) |_i| {
let total = total.clone();
futures += ~[future::spawn(|| {
vec::push(futures, future::spawn(|| {
for uint::range(0u, count) |_i| {
do total.with |count| {
**count += 1u;
}
}
})];
}));
};
for futures.each |f| { f.get() }