Skip to content

Sendable futures #3421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
core: patch from nmatsakis to make futures non-copyable
  • Loading branch information
olsonjeffery committed Sep 8, 2012
commit cf3a7087d22e3a95cee18343a3c74d9cae06b6ab
8 changes: 6 additions & 2 deletions src/libcore/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down