core: patch from nmatsakis to make futures non-copyable
This commit is contained in:
parent
27129c6aba
commit
02ddbadc10
2 changed files with 8 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue