auto merge of #9285 : sfackler/rust/future, r=alexcrichton
The `Drop` implementation was used to prevent `Future` from being implicitly copyable. Since `~fn`s are no longer copyable, this is no longer needed. I added a cfail test to make sure that this is actually the case. I method-ized all of the `Future` creation methods and added a new one, `spawn_with`, which is similar to `task::spawn_with`. I also got rid of some unused imports in tests.
This commit is contained in:
commit
407d179f4e
9 changed files with 117 additions and 97 deletions
|
|
@ -18,7 +18,7 @@
|
|||
extern mod extra;
|
||||
|
||||
use extra::arc;
|
||||
use extra::future;
|
||||
use extra::future::Future;
|
||||
use extra::time;
|
||||
use std::cell::Cell;
|
||||
use std::os;
|
||||
|
|
@ -94,7 +94,7 @@ fn main() {
|
|||
let (new_chan, num_port) = init();
|
||||
let num_chan2 = Cell::new(num_chan.take());
|
||||
let num_port = Cell::new(num_port);
|
||||
let new_future = do future::spawn() {
|
||||
let new_future = do Future::spawn() {
|
||||
let num_chan = num_chan2.take();
|
||||
let num_port1 = num_port.take();
|
||||
thread_ring(i, msg_per_task, num_chan, num_port1)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
extern mod extra;
|
||||
|
||||
use extra::arc;
|
||||
use extra::future;
|
||||
use extra::future::Future;
|
||||
use extra::time;
|
||||
use std::cell::Cell;
|
||||
use std::os;
|
||||
|
|
@ -90,7 +90,7 @@ fn main() {
|
|||
let (new_chan, num_port) = init();
|
||||
let num_chan2 = Cell::new(num_chan.take());
|
||||
let num_port = Cell::new(num_port);
|
||||
let new_future = do future::spawn {
|
||||
let new_future = do Future::spawn {
|
||||
let num_chan = num_chan2.take();
|
||||
let num_port1 = num_port.take();
|
||||
thread_ring(i, msg_per_task, num_chan, num_port1)
|
||||
|
|
|
|||
19
src/test/compile-fail/future_not_copyable.rs
Normal file
19
src/test/compile-fail/future_not_copyable.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
extern mod extra;
|
||||
|
||||
use extra::future::Future;
|
||||
|
||||
fn main() {
|
||||
let f = Future::from_value(());
|
||||
let g = f;
|
||||
f.unwrap(); //~ ERROR use of moved value
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue