librustc: Make || lambdas not infer to procs
This commit is contained in:
@@ -76,7 +76,7 @@ fn print_message() { println("I am running in a different task!"); }
|
|||||||
spawn(print_message);
|
spawn(print_message);
|
||||||
|
|
||||||
// Print something more profound in a different task using a lambda expression
|
// Print something more profound in a different task using a lambda expression
|
||||||
spawn( || println("I am also running in a different task!") );
|
spawn(proc() println("I am also running in a different task!") );
|
||||||
|
|
||||||
// The canonical way to spawn is using `do` notation
|
// The canonical way to spawn is using `do` notation
|
||||||
do spawn {
|
do spawn {
|
||||||
@@ -278,7 +278,7 @@ fn fib(n: u64) -> u64 {
|
|||||||
12586269025
|
12586269025
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut delayed_fib = extra::future::Future::spawn (|| fib(50) );
|
let mut delayed_fib = extra::future::Future::spawn(proc() fib(50));
|
||||||
make_a_sandwich();
|
make_a_sandwich();
|
||||||
println!("fib(50) = {:?}", delayed_fib.get())
|
println!("fib(50) = {:?}", delayed_fib.get())
|
||||||
~~~
|
~~~
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
|
|||||||
let config = Cell::new((*config).clone());
|
let config = Cell::new((*config).clone());
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
|
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
|
||||||
test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
|
test::DynTestFn(proc() { runtest::run(config.take(), testfile.take()) })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
|
pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
|
||||||
@@ -341,5 +341,7 @@ pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::Test
|
|||||||
let config = Cell::new((*config).clone());
|
let config = Cell::new((*config).clone());
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
|
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
|
||||||
test::DynMetricFn(|mm| { runtest::run_metrics(config.take(), testfile.take(), mm) })
|
test::DynMetricFn(proc(mm) {
|
||||||
|
runtest::run_metrics(config.take(), testfile.take(), mm)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_fn() {
|
fn test_from_fn() {
|
||||||
let mut f = Future::from_fn(|| ~"brail");
|
let mut f = Future::from_fn(proc() ~"brail");
|
||||||
assert_eq!(f.get(), ~"brail");
|
assert_eq!(f.get(), ~"brail");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,14 +185,14 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_spawn() {
|
fn test_spawn() {
|
||||||
let mut f = Future::spawn(|| ~"bale");
|
let mut f = Future::spawn(proc() ~"bale");
|
||||||
assert_eq!(f.get(), ~"bale");
|
assert_eq!(f.get(), ~"bale");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_futurefail() {
|
fn test_futurefail() {
|
||||||
let mut f = Future::spawn(|| fail!());
|
let mut f = Future::spawn(proc() fail!());
|
||||||
let _x: ~str = f.get();
|
let _x: ~str = f.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ impl<T> TaskPool<T> {
|
|||||||
let (port, chan) = comm::stream::<Msg<T>>();
|
let (port, chan) = comm::stream::<Msg<T>>();
|
||||||
let init_fn = init_fn_factory();
|
let init_fn = init_fn_factory();
|
||||||
|
|
||||||
let task_body: proc() = || {
|
let task_body: proc() = proc() {
|
||||||
let local_data = init_fn(i);
|
let local_data = init_fn(i);
|
||||||
loop {
|
loop {
|
||||||
match port.recv() {
|
match port.recv() {
|
||||||
@@ -98,11 +98,11 @@ impl<T> TaskPool<T> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_task_pool() {
|
fn test_task_pool() {
|
||||||
let f: || -> proc(uint) -> uint = || {
|
let f: || -> proc(uint) -> uint = || {
|
||||||
let g: proc(uint) -> uint = |i| i;
|
let g: proc(uint) -> uint = proc(i) i;
|
||||||
g
|
g
|
||||||
};
|
};
|
||||||
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
|
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
|
||||||
8.times(|| {
|
8.times(|| {
|
||||||
pool.execute(|i| println!("Hello from thread {}!", *i));
|
pool.execute(proc(i) println!("Hello from thread {}!", *i));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -912,7 +912,7 @@ pub fn run_test(force_ignore: bool,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DynTestFn(f) => run_test_inner(desc, monitor_ch, f),
|
DynTestFn(f) => run_test_inner(desc, monitor_ch, f),
|
||||||
StaticTestFn(f) => run_test_inner(desc, monitor_ch, || f())
|
StaticTestFn(f) => run_test_inner(desc, monitor_ch, proc() f())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,7 +1209,7 @@ mod tests {
|
|||||||
ignore: true,
|
ignore: true,
|
||||||
should_fail: false
|
should_fail: false
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| f()),
|
testfn: DynTestFn(proc() f()),
|
||||||
};
|
};
|
||||||
let (p, ch) = stream();
|
let (p, ch) = stream();
|
||||||
let ch = SharedChan::new(ch);
|
let ch = SharedChan::new(ch);
|
||||||
@@ -1227,7 +1227,7 @@ mod tests {
|
|||||||
ignore: true,
|
ignore: true,
|
||||||
should_fail: false
|
should_fail: false
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| f()),
|
testfn: DynTestFn(proc() f()),
|
||||||
};
|
};
|
||||||
let (p, ch) = stream();
|
let (p, ch) = stream();
|
||||||
let ch = SharedChan::new(ch);
|
let ch = SharedChan::new(ch);
|
||||||
@@ -1245,7 +1245,7 @@ mod tests {
|
|||||||
ignore: false,
|
ignore: false,
|
||||||
should_fail: true
|
should_fail: true
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| f()),
|
testfn: DynTestFn(proc() f()),
|
||||||
};
|
};
|
||||||
let (p, ch) = stream();
|
let (p, ch) = stream();
|
||||||
let ch = SharedChan::new(ch);
|
let ch = SharedChan::new(ch);
|
||||||
@@ -1263,7 +1263,7 @@ mod tests {
|
|||||||
ignore: false,
|
ignore: false,
|
||||||
should_fail: true
|
should_fail: true
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| f()),
|
testfn: DynTestFn(proc() f()),
|
||||||
};
|
};
|
||||||
let (p, ch) = stream();
|
let (p, ch) = stream();
|
||||||
let ch = SharedChan::new(ch);
|
let ch = SharedChan::new(ch);
|
||||||
@@ -1318,7 +1318,7 @@ mod tests {
|
|||||||
ignore: true,
|
ignore: true,
|
||||||
should_fail: false,
|
should_fail: false,
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| {}),
|
testfn: DynTestFn(proc() {}),
|
||||||
},
|
},
|
||||||
TestDescAndFn {
|
TestDescAndFn {
|
||||||
desc: TestDesc {
|
desc: TestDesc {
|
||||||
@@ -1326,7 +1326,7 @@ mod tests {
|
|||||||
ignore: false,
|
ignore: false,
|
||||||
should_fail: false
|
should_fail: false
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| {}),
|
testfn: DynTestFn(proc() {}),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let filtered = filter_tests(&opts, tests);
|
let filtered = filter_tests(&opts, tests);
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ pub fn monitor(f: proc(@diagnostic::Emitter)) {
|
|||||||
task_builder.opts.stack_size = Some(STACK_SIZE);
|
task_builder.opts.stack_size = Some(STACK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
match task_builder.try(|| {
|
match task_builder.try(proc() {
|
||||||
let ch = ch_capture.clone();
|
let ch = ch_capture.clone();
|
||||||
// The 'diagnostics emitter'. Every error, warning, etc. should
|
// The 'diagnostics emitter'. Every error, warning, etc. should
|
||||||
// go through this function.
|
// go through this function.
|
||||||
@@ -403,6 +403,6 @@ pub fn main() {
|
|||||||
|
|
||||||
pub fn main_args(args: &[~str]) -> int {
|
pub fn main_args(args: &[~str]) -> int {
|
||||||
let owned_args = args.to_owned();
|
let owned_args = args.to_owned();
|
||||||
monitor(|demitter| run_compiler(owned_args, demitter));
|
monitor(proc(demitter) run_compiler(owned_args, demitter));
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2905,8 +2905,13 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||||||
_match::check_match(fcx, expr, discrim, *arms);
|
_match::check_match(fcx, expr, discrim, *arms);
|
||||||
}
|
}
|
||||||
ast::ExprFnBlock(ref decl, ref body) => {
|
ast::ExprFnBlock(ref decl, ref body) => {
|
||||||
check_expr_fn(fcx, expr, None,
|
check_expr_fn(fcx,
|
||||||
decl, body, Vanilla, expected);
|
expr,
|
||||||
|
Some(ast::BorrowedSigil),
|
||||||
|
decl,
|
||||||
|
body,
|
||||||
|
Vanilla,
|
||||||
|
expected);
|
||||||
}
|
}
|
||||||
ast::ExprProc(ref decl, ref body) => {
|
ast::ExprProc(ref decl, ref body) => {
|
||||||
check_expr_fn(fcx,
|
check_expr_fn(fcx,
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ impl CtxMethods for BuildContext {
|
|||||||
let psp = package_script_path.clone();
|
let psp = package_script_path.clone();
|
||||||
let ws = workspace.clone();
|
let ws = workspace.clone();
|
||||||
let pid = pkgid.clone();
|
let pid = pkgid.clone();
|
||||||
prep.exec(|exec| {
|
prep.exec(proc(exec) {
|
||||||
let mut pscript = PkgScript::parse(subsysroot.clone(),
|
let mut pscript = PkgScript::parse(subsysroot.clone(),
|
||||||
psp.clone(),
|
psp.clone(),
|
||||||
&ws,
|
&ws,
|
||||||
@@ -636,7 +636,7 @@ impl CtxMethods for BuildContext {
|
|||||||
let sub_target_ex = target_exec.clone();
|
let sub_target_ex = target_exec.clone();
|
||||||
let sub_target_lib = target_lib.clone();
|
let sub_target_lib = target_lib.clone();
|
||||||
let sub_build_inputs = build_inputs.to_owned();
|
let sub_build_inputs = build_inputs.to_owned();
|
||||||
prep.exec(|exe_thing| {
|
prep.exec(proc(exe_thing) {
|
||||||
let mut outputs = ~[];
|
let mut outputs = ~[];
|
||||||
// Declare all the *inputs* to the declared input too, as inputs
|
// Declare all the *inputs* to the declared input too, as inputs
|
||||||
for executable in subex.iter() {
|
for executable in subex.iter() {
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ impl PkgSrc {
|
|||||||
let sub_deps = deps.clone();
|
let sub_deps = deps.clone();
|
||||||
let inputs = inputs_to_discover.map(|&(ref k, ref p)|
|
let inputs = inputs_to_discover.map(|&(ref k, ref p)|
|
||||||
(k.clone(), p.as_str().unwrap().to_owned()));
|
(k.clone(), p.as_str().unwrap().to_owned()));
|
||||||
prep.exec(|exec| {
|
prep.exec(proc(exec) {
|
||||||
for &(ref kind, ref p) in inputs.iter() {
|
for &(ref kind, ref p) in inputs.iter() {
|
||||||
let pth = Path::new(p.clone());
|
let pth = Path::new(p.clone());
|
||||||
exec.discover_input(*kind, *p, if *kind == ~"file" {
|
exec.discover_input(*kind, *p, if *kind == ~"file" {
|
||||||
|
|||||||
@@ -1092,7 +1092,7 @@ mod test {
|
|||||||
let handle2 = Cell::new(sched2.make_handle());
|
let handle2 = Cell::new(sched2.make_handle());
|
||||||
let tasksFriendHandle = Cell::new(sched2.make_handle());
|
let tasksFriendHandle = Cell::new(sched2.make_handle());
|
||||||
|
|
||||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
let on_exit: proc(UnwindResult) = proc(exit_status) {
|
||||||
handle1.take().send(Shutdown);
|
handle1.take().send(Shutdown);
|
||||||
handle2.take().send(Shutdown);
|
handle2.take().send(Shutdown);
|
||||||
assert!(exit_status.is_success());
|
assert!(exit_status.is_success());
|
||||||
@@ -1106,7 +1106,7 @@ mod test {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let test_function: proc() = || {
|
let test_function: proc() = proc() {
|
||||||
let io = unsafe { local_io() };
|
let io = unsafe { local_io() };
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
let maybe_socket = io.udp_bind(addr);
|
let maybe_socket = io.udp_bind(addr);
|
||||||
|
|||||||
@@ -214,29 +214,29 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke() {
|
fn smoke() {
|
||||||
smalltest(|mut server| {
|
smalltest(proc(mut server) {
|
||||||
let mut buf = [0];
|
let mut buf = [0];
|
||||||
server.read(buf);
|
server.read(buf);
|
||||||
assert!(buf[0] == 99);
|
assert!(buf[0] == 99);
|
||||||
}, |mut client| {
|
}, proc(mut client) {
|
||||||
client.write([99]);
|
client.write([99]);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_eof() {
|
fn read_eof() {
|
||||||
smalltest(|mut server| {
|
smalltest(proc(mut server) {
|
||||||
let mut buf = [0];
|
let mut buf = [0];
|
||||||
assert!(server.read(buf).is_none());
|
assert!(server.read(buf).is_none());
|
||||||
assert!(server.read(buf).is_none());
|
assert!(server.read(buf).is_none());
|
||||||
}, |_client| {
|
}, proc(_client) {
|
||||||
// drop the client
|
// drop the client
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn write_begone() {
|
fn write_begone() {
|
||||||
smalltest(|mut server| {
|
smalltest(proc(mut server) {
|
||||||
let buf = [0];
|
let buf = [0];
|
||||||
let mut stop = false;
|
let mut stop = false;
|
||||||
while !stop{
|
while !stop{
|
||||||
@@ -248,7 +248,7 @@ mod tests {
|
|||||||
server.write(buf);
|
server.write(buf);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, |_client| {
|
}, proc(_client) {
|
||||||
// drop the client
|
// drop the client
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ mod test {
|
|||||||
do run_in_bare_thread {
|
do run_in_bare_thread {
|
||||||
local_ptr::init_tls_key();
|
local_ptr::init_tls_key();
|
||||||
let mut sched = ~new_test_uv_sched();
|
let mut sched = ~new_test_uv_sched();
|
||||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||||
Local::put(task);
|
Local::put(task);
|
||||||
let task: ~Task = Local::take();
|
let task: ~Task = Local::take();
|
||||||
cleanup_task(task);
|
cleanup_task(task);
|
||||||
@@ -146,11 +146,11 @@ mod test {
|
|||||||
do run_in_bare_thread {
|
do run_in_bare_thread {
|
||||||
local_ptr::init_tls_key();
|
local_ptr::init_tls_key();
|
||||||
let mut sched = ~new_test_uv_sched();
|
let mut sched = ~new_test_uv_sched();
|
||||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||||
Local::put(task);
|
Local::put(task);
|
||||||
let task: ~Task = Local::take();
|
let task: ~Task = Local::take();
|
||||||
cleanup_task(task);
|
cleanup_task(task);
|
||||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||||
Local::put(task);
|
Local::put(task);
|
||||||
let task: ~Task = Local::take();
|
let task: ~Task = Local::take();
|
||||||
cleanup_task(task);
|
cleanup_task(task);
|
||||||
@@ -163,7 +163,7 @@ mod test {
|
|||||||
do run_in_bare_thread {
|
do run_in_bare_thread {
|
||||||
local_ptr::init_tls_key();
|
local_ptr::init_tls_key();
|
||||||
let mut sched = ~new_test_uv_sched();
|
let mut sched = ~new_test_uv_sched();
|
||||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||||
Local::put(task);
|
Local::put(task);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -179,7 +179,7 @@ mod test {
|
|||||||
do run_in_bare_thread {
|
do run_in_bare_thread {
|
||||||
local_ptr::init_tls_key();
|
local_ptr::init_tls_key();
|
||||||
let mut sched = ~new_test_uv_sched();
|
let mut sched = ~new_test_uv_sched();
|
||||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||||
Local::put(task);
|
Local::put(task);
|
||||||
|
|
||||||
let res = Local::borrow(|_task: &mut Task| {
|
let res = Local::borrow(|_task: &mut Task| {
|
||||||
|
|||||||
@@ -340,14 +340,14 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
|
|||||||
|
|
||||||
// When the main task exits, after all the tasks in the main
|
// When the main task exits, after all the tasks in the main
|
||||||
// task tree, shut down the schedulers and set the exit code.
|
// task tree, shut down the schedulers and set the exit code.
|
||||||
let handles = Cell::new(handles);
|
let handles = handles;
|
||||||
let on_exit: proc(UnwindResult) = |exit_success| {
|
let on_exit: proc(UnwindResult) = proc(exit_success) {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(!(*exited_already.get()).swap(true, SeqCst),
|
assert!(!(*exited_already.get()).swap(true, SeqCst),
|
||||||
"the runtime already exited");
|
"the runtime already exited");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut handles = handles.take();
|
let mut handles = handles;
|
||||||
for handle in handles.mut_iter() {
|
for handle in handles.mut_iter() {
|
||||||
handle.send(Shutdown);
|
handle.send(Shutdown);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -979,7 +979,7 @@ mod test {
|
|||||||
assert!(Task::on_appropriate_sched());
|
assert!(Task::on_appropriate_sched());
|
||||||
};
|
};
|
||||||
|
|
||||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
let on_exit: proc(UnwindResult) = proc(exit_status) {
|
||||||
rtassert!(exit_status.is_success())
|
rtassert!(exit_status.is_success())
|
||||||
};
|
};
|
||||||
task.death.on_exit = Some(on_exit);
|
task.death.on_exit = Some(on_exit);
|
||||||
@@ -1193,12 +1193,15 @@ mod test {
|
|||||||
|
|
||||||
let thread = do Thread::start {
|
let thread = do Thread::start {
|
||||||
let mut sched = sched.take();
|
let mut sched = sched.take();
|
||||||
let bootstrap_task = ~Task::new_root(&mut sched.stack_pool, None, ||());
|
let bootstrap_task =
|
||||||
|
~Task::new_root(&mut sched.stack_pool,
|
||||||
|
None,
|
||||||
|
proc()());
|
||||||
sched.bootstrap(bootstrap_task);
|
sched.bootstrap(bootstrap_task);
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut stack_pool = StackPool::new();
|
let mut stack_pool = StackPool::new();
|
||||||
let task = ~Task::new_root(&mut stack_pool, None, ||());
|
let task = ~Task::new_root(&mut stack_pool, None, proc()());
|
||||||
handle.send(TaskFromFriend(task));
|
handle.send(TaskFromFriend(task));
|
||||||
|
|
||||||
handle.send(Shutdown);
|
handle.send(Shutdown);
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ impl Coroutine {
|
|||||||
|
|
||||||
fn build_start_wrapper(start: proc()) -> proc() {
|
fn build_start_wrapper(start: proc()) -> proc() {
|
||||||
let start_cell = Cell::new(start);
|
let start_cell = Cell::new(start);
|
||||||
let wrapper: proc() = || {
|
let wrapper: proc() = proc() {
|
||||||
// First code after swap to this new context. Run our
|
// First code after swap to this new context. Run our
|
||||||
// cleanup job.
|
// cleanup job.
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -712,10 +712,10 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn unwind() {
|
fn unwind() {
|
||||||
do run_in_newsched_task() {
|
do run_in_newsched_task() {
|
||||||
let result = spawntask_try(||());
|
let result = spawntask_try(proc()());
|
||||||
rtdebug!("trying first assert");
|
rtdebug!("trying first assert");
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
let result = spawntask_try(|| fail!());
|
let result = spawntask_try(proc() fail!());
|
||||||
rtdebug!("trying second assert");
|
rtdebug!("trying second assert");
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,10 +83,11 @@ pub fn run_in_uv_task_core(f: proc()) {
|
|||||||
use rt::sched::Shutdown;
|
use rt::sched::Shutdown;
|
||||||
|
|
||||||
let mut sched = ~new_test_uv_sched();
|
let mut sched = ~new_test_uv_sched();
|
||||||
let exit_handle = Cell::new(sched.make_handle());
|
let exit_handle = sched.make_handle();
|
||||||
|
|
||||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
|
||||||
exit_handle.take().send(Shutdown);
|
let mut exit_handle = exit_handle;
|
||||||
|
exit_handle.send(Shutdown);
|
||||||
rtassert!(exit_status.is_success());
|
rtassert!(exit_status.is_success());
|
||||||
};
|
};
|
||||||
let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
|
let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
|
||||||
@@ -99,10 +100,11 @@ pub fn run_in_newsched_task_core(f: proc()) {
|
|||||||
use rt::sched::Shutdown;
|
use rt::sched::Shutdown;
|
||||||
|
|
||||||
let mut sched = ~new_test_sched();
|
let mut sched = ~new_test_sched();
|
||||||
let exit_handle = Cell::new(sched.make_handle());
|
let exit_handle = sched.make_handle();
|
||||||
|
|
||||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
|
||||||
exit_handle.take().send(Shutdown);
|
let mut exit_handle = exit_handle;
|
||||||
|
exit_handle.send(Shutdown);
|
||||||
rtassert!(exit_status.is_success());
|
rtassert!(exit_status.is_success());
|
||||||
};
|
};
|
||||||
let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
|
let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
|
||||||
@@ -244,10 +246,10 @@ pub fn run_in_mt_newsched_task(f: proc()) {
|
|||||||
scheds.push(sched);
|
scheds.push(sched);
|
||||||
}
|
}
|
||||||
|
|
||||||
let handles = Cell::new(handles);
|
let handles = handles; // Work around not being able to capture mut
|
||||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
|
||||||
let mut handles = handles.take();
|
|
||||||
// Tell schedulers to exit
|
// Tell schedulers to exit
|
||||||
|
let mut handles = handles;
|
||||||
for handle in handles.mut_iter() {
|
for handle in handles.mut_iter() {
|
||||||
handle.send(Shutdown);
|
handle.send(Shutdown);
|
||||||
}
|
}
|
||||||
@@ -319,8 +321,9 @@ pub fn spawntask_random(f: proc()) {
|
|||||||
pub fn spawntask_try(f: proc()) -> Result<(),()> {
|
pub fn spawntask_try(f: proc()) -> Result<(),()> {
|
||||||
|
|
||||||
let (port, chan) = oneshot();
|
let (port, chan) = oneshot();
|
||||||
let chan = Cell::new(chan);
|
let on_exit: proc(UnwindResult) = proc(exit_status) {
|
||||||
let on_exit: proc(UnwindResult) = |exit_status| chan.take().send(exit_status);
|
chan.send(exit_status)
|
||||||
|
};
|
||||||
|
|
||||||
let mut new_task = Task::build_root(None, f);
|
let mut new_task = Task::build_root(None, f);
|
||||||
new_task.death.on_exit = Some(on_exit);
|
new_task.death.on_exit = Some(on_exit);
|
||||||
@@ -348,7 +351,9 @@ pub fn spawntask_thread(f: proc()) -> Thread {
|
|||||||
pub fn with_test_task(blk: proc(~Task) -> ~Task) {
|
pub fn with_test_task(blk: proc(~Task) -> ~Task) {
|
||||||
do run_in_bare_thread {
|
do run_in_bare_thread {
|
||||||
let mut sched = ~new_test_sched();
|
let mut sched = ~new_test_sched();
|
||||||
let task = blk(~Task::new_root(&mut sched.stack_pool, None, ||{}));
|
let task = blk(~Task::new_root(&mut sched.stack_pool,
|
||||||
|
None,
|
||||||
|
proc() {}));
|
||||||
cleanup_task(task);
|
cleanup_task(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,13 +280,13 @@ impl TaskBuilder {
|
|||||||
let prev_gen_body = match prev_gen_body {
|
let prev_gen_body = match prev_gen_body {
|
||||||
Some(gen) => gen,
|
Some(gen) => gen,
|
||||||
None => {
|
None => {
|
||||||
let f: proc(proc()) -> proc() = |body| body;
|
let f: proc(proc()) -> proc() = proc(body) body;
|
||||||
f
|
f
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let prev_gen_body = Cell::new(prev_gen_body);
|
let prev_gen_body = Cell::new(prev_gen_body);
|
||||||
let next_gen_body = {
|
let next_gen_body = {
|
||||||
let f: proc(proc()) -> proc() = |body| {
|
let f: proc(proc()) -> proc() = proc(body) {
|
||||||
let prev_gen_body = prev_gen_body.take();
|
let prev_gen_body = prev_gen_body.take();
|
||||||
wrapper(prev_gen_body(body))
|
wrapper(prev_gen_body(body))
|
||||||
};
|
};
|
||||||
@@ -551,7 +551,7 @@ fn test_add_wrapper() {
|
|||||||
let ch = Cell::new(ch);
|
let ch = Cell::new(ch);
|
||||||
do b0.add_wrapper |body| {
|
do b0.add_wrapper |body| {
|
||||||
let ch = Cell::new(ch.take());
|
let ch = Cell::new(ch.take());
|
||||||
let result: proc() = || {
|
let result: proc() = proc() {
|
||||||
let ch = ch.take();
|
let ch = ch.take();
|
||||||
body();
|
body();
|
||||||
ch.send(());
|
ch.send(());
|
||||||
@@ -765,7 +765,7 @@ fn test_child_doesnt_ref_parent() {
|
|||||||
// valgrind-friendly. try this at home, instead..!)
|
// valgrind-friendly. try this at home, instead..!)
|
||||||
static generations: uint = 16;
|
static generations: uint = 16;
|
||||||
fn child_no(x: uint) -> proc() {
|
fn child_no(x: uint) -> proc() {
|
||||||
return || {
|
return proc() {
|
||||||
if x < generations {
|
if x < generations {
|
||||||
let mut t = task();
|
let mut t = task();
|
||||||
t.unwatched();
|
t.unwatched();
|
||||||
@@ -783,7 +783,7 @@ fn test_simple_newsched_spawn() {
|
|||||||
use rt::test::run_in_uv_task;
|
use rt::test::run_in_uv_task;
|
||||||
|
|
||||||
do run_in_uv_task {
|
do run_in_uv_task {
|
||||||
spawn(||())
|
spawn(proc()())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: proc()) {
|
|||||||
if opts.notify_chan.is_some() {
|
if opts.notify_chan.is_some() {
|
||||||
let notify_chan = opts.notify_chan.take_unwrap();
|
let notify_chan = opts.notify_chan.take_unwrap();
|
||||||
let notify_chan = Cell::new(notify_chan);
|
let notify_chan = Cell::new(notify_chan);
|
||||||
let on_exit: proc(UnwindResult) = |task_result| {
|
let on_exit: proc(UnwindResult) = proc(task_result) {
|
||||||
notify_chan.take().send(task_result)
|
notify_chan.take().send(task_result)
|
||||||
};
|
};
|
||||||
task.death.on_exit = Some(on_exit);
|
task.death.on_exit = Some(on_exit);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ fn fib(n: int) -> int {
|
|||||||
|
|
||||||
let (p, ch) = stream();
|
let (p, ch) = stream();
|
||||||
let ch = SharedChan::new(ch);
|
let ch = SharedChan::new(ch);
|
||||||
let _t = task::spawn(|| pfib(&ch, n) );
|
let _t = task::spawn(proc() pfib(&ch, n) );
|
||||||
p.recv()
|
p.recv()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,5 +33,5 @@ fn main() {
|
|||||||
};
|
};
|
||||||
let n = from_str::<uint>(args[1]).unwrap();
|
let n = from_str::<uint>(args[1]).unwrap();
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < n { task::spawn(|| f(n) ); i += 1u; }
|
while i < n { task::spawn(proc() f(n) ); i += 1u; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn box_imm() {
|
|||||||
|
|
||||||
let v = ~3;
|
let v = ~3;
|
||||||
let _w = &v;
|
let _w = &v;
|
||||||
task::spawn(|| {
|
task::spawn(proc() {
|
||||||
info!("v={}", *v);
|
info!("v={}", *v);
|
||||||
//~^ ERROR cannot move
|
//~^ ERROR cannot move
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ pub fn main() {
|
|||||||
// you get two error reports here.
|
// you get two error reports here.
|
||||||
let bar = ~3;
|
let bar = ~3;
|
||||||
let _g = || { //~ ERROR capture of moved value
|
let _g = || { //~ ERROR capture of moved value
|
||||||
let _h: proc() -> int = || *bar; //~ ERROR capture of moved value
|
let _h: proc() -> int = proc() *bar; //~ ERROR capture of moved value
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ fn call_f(f: proc() -> int) -> int {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let t = ~3;
|
let t = ~3;
|
||||||
|
|
||||||
call_f(|| { *t + 1 });
|
call_f(proc() { *t + 1 });
|
||||||
call_f(|| { *t + 1 }); //~ ERROR capture of moved value
|
call_f(proc() { *t + 1 }); //~ ERROR capture of moved value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fn foo(_x: @uint) {}
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = @3u;
|
let x = @3u;
|
||||||
let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
|
let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||||
let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
|
let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||||
let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
|
let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ fn failfn() {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let y = ~0;
|
let y = ~0;
|
||||||
let x: @proc() = @(|| {
|
let x: @proc() = @(proc() {
|
||||||
error!("{:?}", y.clone());
|
error!("{:?}", y.clone());
|
||||||
});
|
});
|
||||||
failfn();
|
failfn();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ fn asBlock(f: || -> uint) -> uint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = asSendfn(|| 22u);
|
let x = asSendfn(proc() 22u);
|
||||||
assert_eq!(x, 22u);
|
assert_eq!(x, 22u);
|
||||||
let x = asBlock(|| 22u);
|
let x = asBlock(|| 22u);
|
||||||
assert_eq!(x, 22u);
|
assert_eq!(x, 22u);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let bar = ~3;
|
let bar = ~3;
|
||||||
let h: proc() -> int = || *bar;
|
let h: proc() -> int = proc() *bar;
|
||||||
assert_eq!(h(), 3);
|
assert_eq!(h(), 3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ use std::ptr;
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = ~3;
|
let x = ~3;
|
||||||
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
let snd_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
let snd_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
assert_eq!(snd_move(), y);
|
assert_eq!(snd_move(), y);
|
||||||
|
|
||||||
let x = ~4;
|
let x = ~4;
|
||||||
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
let lam_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
let lam_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
assert_eq!(lam_move(), y);
|
assert_eq!(lam_move(), y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ use std::task;
|
|||||||
fn child2(_s: ~str) { }
|
fn child2(_s: ~str) { }
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let _x = task::spawn(|| child2(~"hi"));
|
let _x = task::spawn(proc() child2(~"hi"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use std::task;
|
|||||||
fn adder(x: @int, y: @int) -> int { return *x + *y; }
|
fn adder(x: @int, y: @int) -> int { return *x + *y; }
|
||||||
fn failer() -> @int { fail!(); }
|
fn failer() -> @int { fail!(); }
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
assert!(task::try(|| {
|
assert!(task::try(proc() {
|
||||||
adder(@2, failer()); ()
|
adder(@2, failer()); ()
|
||||||
}).is_err());
|
}).is_err());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ struct Pair {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let z = ~Pair { a : 10, b : 12};
|
let z = ~Pair { a : 10, b : 12};
|
||||||
|
|
||||||
let f: proc() = || {
|
let f: proc() = proc() {
|
||||||
assert_eq!(z.a, 10);
|
assert_eq!(z.a, 10);
|
||||||
assert_eq!(z.b, 12);
|
assert_eq!(z.b, 12);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use std::task;
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (p, ch) = stream();
|
let (p, ch) = stream();
|
||||||
let _t = task::spawn(|| child(&ch) );
|
let _t = task::spawn(proc() child(&ch));
|
||||||
let y = p.recv();
|
let y = p.recv();
|
||||||
error!("received");
|
error!("received");
|
||||||
error!("{:?}", y);
|
error!("{:?}", y);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ mod map_reduce {
|
|||||||
for i in inputs.iter() {
|
for i in inputs.iter() {
|
||||||
let ctrl = ctrl.clone();
|
let ctrl = ctrl.clone();
|
||||||
let i = i.clone();
|
let i = i.clone();
|
||||||
task::spawn(|| map_task(ctrl.clone(), i.clone()) );
|
task::spawn(proc() map_task(ctrl.clone(), i.clone()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type rsrc_loader = proc(path: &Path) -> result::Result<~str, ~str>;
|
|||||||
|
|
||||||
fn tester()
|
fn tester()
|
||||||
{
|
{
|
||||||
let loader: rsrc_loader = |_path| {result::Ok(~"more blah")};
|
let loader: rsrc_loader = proc(_path) {result::Ok(~"more blah")};
|
||||||
|
|
||||||
let path = path::Path::new("blah");
|
let path = path::Path::new("blah");
|
||||||
assert!(loader(&path).is_ok());
|
assert!(loader(&path).is_ok());
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ enum Msg
|
|||||||
fn foo(name: ~str, samples_chan: Chan<Msg>) {
|
fn foo(name: ~str, samples_chan: Chan<Msg>) {
|
||||||
do task::spawn
|
do task::spawn
|
||||||
{
|
{
|
||||||
let callback: SamplesFn =
|
let callback: SamplesFn = proc(buffer) {
|
||||||
|buffer|
|
|
||||||
{
|
|
||||||
for i in range(0u, buffer.len()) {
|
for i in range(0u, buffer.len()) {
|
||||||
error!("{}: {}", i, buffer[i])
|
error!("{}: {}", i, buffer[i])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fn producer(c: &Chan<~[u8]>) {
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (p, ch) = stream::<~[u8]>();
|
let (p, ch) = stream::<~[u8]>();
|
||||||
let _prod = task::spawn(|| producer(&ch) );
|
let _prod = task::spawn(proc() producer(&ch) );
|
||||||
|
|
||||||
let _data: ~[u8] = p.recv();
|
let _data: ~[u8] = p.recv();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
// Test that the lambda kind is inferred correctly as a return
|
// Test that the lambda kind is inferred correctly as a return
|
||||||
// expression
|
// expression
|
||||||
|
|
||||||
fn unique() -> proc() { return || (); }
|
fn unique() -> proc() { return proc() (); }
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
// Test that the lambda kind is inferred correctly as a return
|
// Test that the lambda kind is inferred correctly as a return
|
||||||
// expression
|
// expression
|
||||||
|
|
||||||
fn unique() -> proc() { || () }
|
fn unique() -> proc() { proc() () }
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,6 @@ pub fn main() {
|
|||||||
assert_eq!(q.y, !(p.y));
|
assert_eq!(q.y, !(p.y));
|
||||||
|
|
||||||
// Issue #1733
|
// Issue #1733
|
||||||
let result: proc(int) = |_|();
|
let result: proc(int) = proc(_)();
|
||||||
result(p[true]);
|
result(p[true]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ fn test05_start(f: proc(int)) {
|
|||||||
|
|
||||||
fn test05() {
|
fn test05() {
|
||||||
let three = ~3;
|
let three = ~3;
|
||||||
let fn_to_send: proc(int) = |n| {
|
let fn_to_send: proc(int) = proc(n) {
|
||||||
error!("{}", *three + n); // will copy x into the closure
|
error!("{}", *three + n); // will copy x into the closure
|
||||||
assert_eq!(*three, 3);
|
assert_eq!(*three, 3);
|
||||||
};
|
};
|
||||||
let fn_to_send = Cell::new(fn_to_send);
|
let fn_to_send = Cell::new(fn_to_send);
|
||||||
task::spawn(|| {
|
task::spawn(proc() {
|
||||||
test05_start(fn_to_send.take());
|
test05_start(fn_to_send.take());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ fn x(s: ~str, n: int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
task::spawn(|| x(~"hello from first spawned fn", 65) );
|
task::spawn(proc() x(~"hello from first spawned fn", 65) );
|
||||||
task::spawn(|| x(~"hello from second spawned fn", 66) );
|
task::spawn(proc() x(~"hello from second spawned fn", 66) );
|
||||||
task::spawn(|| x(~"hello from third spawned fn", 67) );
|
task::spawn(proc() x(~"hello from third spawned fn", 67) );
|
||||||
let mut i: int = 30;
|
let mut i: int = 30;
|
||||||
while i > 0 { i = i - 1; info!("parent sleeping"); task::deschedule(); }
|
while i > 0 { i = i - 1; info!("parent sleeping"); task::deschedule(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,5 @@ fn iotask(_cx: &ctx, ip: ~str) {
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (_p, ch) = stream::<int>();
|
let (_p, ch) = stream::<int>();
|
||||||
task::spawn(|| iotask(&ch, ~"localhost") );
|
task::spawn(proc() iotask(&ch, ~"localhost") );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ extern mod extra;
|
|||||||
use std::task;
|
use std::task;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
task::spawn(|| child(10) );
|
task::spawn(proc() child(10) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child(i: int) { error!("{}", i); assert!((i == 10)); }
|
fn child(i: int) { error!("{}", i); assert!((i == 10)); }
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
use std::task;
|
use std::task;
|
||||||
|
|
||||||
pub fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
|
pub fn main() { task::spawn(proc() child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
|
||||||
|
|
||||||
fn child(args: (int, int, int, int, int, int, int, int, int)) {
|
fn child(args: (int, int, int, int, int, int, int, int, int)) {
|
||||||
let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
|
let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ use std::task;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut t = task::task();
|
let mut t = task::task();
|
||||||
t.sched_mode(task::SingleThreaded);
|
t.sched_mode(task::SingleThreaded);
|
||||||
t.spawn(|| ());
|
t.spawn(proc() ());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub fn main() {
|
|||||||
name: DynTestName(~"test"),
|
name: DynTestName(~"test"),
|
||||||
should_fail: false
|
should_fail: false
|
||||||
},
|
},
|
||||||
testfn: DynTestFn(|| ()),
|
testfn: DynTestFn(proc() ()),
|
||||||
};
|
};
|
||||||
do_swap(&mut test);
|
do_swap(&mut test);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fn test05_start(ch : &Chan<int>) {
|
|||||||
|
|
||||||
fn test05() {
|
fn test05() {
|
||||||
let (po, ch) = comm::stream();
|
let (po, ch) = comm::stream();
|
||||||
task::spawn(|| test05_start(&ch) );
|
task::spawn(proc() test05_start(&ch) );
|
||||||
let mut value: int = po.recv();
|
let mut value: int = po.recv();
|
||||||
error!("{}", value);
|
error!("{}", value);
|
||||||
value = po.recv();
|
value = po.recv();
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ pub fn main() { test00(); }
|
|||||||
fn start() { info!("Started / Finished task."); }
|
fn start() { info!("Started / Finished task."); }
|
||||||
|
|
||||||
fn test00() {
|
fn test00() {
|
||||||
task::try(|| start() );
|
task::try(proc() start() );
|
||||||
info!("Completing.");
|
info!("Completing.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ fn start(c: &comm::Chan<comm::Chan<~str>>) {
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (p, ch) = comm::stream();
|
let (p, ch) = comm::stream();
|
||||||
let _child = task::spawn(|| start(&ch) );
|
let _child = task::spawn(proc() start(&ch) );
|
||||||
|
|
||||||
let c = p.recv();
|
let c = p.recv();
|
||||||
c.send(~"A");
|
c.send(~"A");
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ fn start(c: &comm::Chan<comm::Chan<int>>) {
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (p, ch) = comm::stream();
|
let (p, ch) = comm::stream();
|
||||||
let _child = task::spawn(|| start(&ch) );
|
let _child = task::spawn(proc() start(&ch) );
|
||||||
let _c = p.recv();
|
let _c = p.recv();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ fn start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
info!("Check that we don't deadlock.");
|
info!("Check that we don't deadlock.");
|
||||||
let (_p, ch) = comm::stream();
|
let (_p, ch) = comm::stream();
|
||||||
task::try(|| start(&ch, 0, 10) );
|
task::try(proc() start(&ch, 0, 10) );
|
||||||
info!("Joined task");
|
info!("Joined task");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub fn main() {
|
|||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
info!("{}", i);
|
info!("{}", i);
|
||||||
let ch = ch.clone();
|
let ch = ch.clone();
|
||||||
task::spawn({let i = i; || child(i, &ch)});
|
task::spawn({let i = i; proc() child(i, &ch)});
|
||||||
i = i - 1;
|
i = i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ pub fn main() {
|
|||||||
// the child's point of view the receiver may die. We should
|
// the child's point of view the receiver may die. We should
|
||||||
// drop messages on the floor in this case, and not crash!
|
// drop messages on the floor in this case, and not crash!
|
||||||
let (p, ch) = comm::stream();
|
let (p, ch) = comm::stream();
|
||||||
task::spawn(|| start(&ch, 10));
|
task::spawn(proc() start(&ch, 10));
|
||||||
p.recv();
|
p.recv();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,5 @@ fn f() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
task::spawn(|| f() );
|
task::spawn(proc() f() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ fn test00() {
|
|||||||
results.push(builder.future_result());
|
results.push(builder.future_result());
|
||||||
builder.spawn({
|
builder.spawn({
|
||||||
let i = i;
|
let i = i;
|
||||||
|| test00_start(&ch, i, number_of_messages)
|
proc() test00_start(&ch, i, number_of_messages)
|
||||||
});
|
});
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ extern mod extra;
|
|||||||
use std::task;
|
use std::task;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
task::spawn(|| child(~"Hello") );
|
task::spawn(proc() child(~"Hello") );
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child(_s: ~str) {
|
fn child(_s: ~str) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pub fn main() {
|
|||||||
let x = ~1;
|
let x = ~1;
|
||||||
let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint;
|
let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
|
|
||||||
task::spawn(|| {
|
task::spawn(proc() {
|
||||||
let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint;
|
let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||||
ch.send(x_in_child);
|
ch.send(x_in_child);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ fn test_tempdir() {
|
|||||||
|
|
||||||
fn test_rm_tempdir() {
|
fn test_rm_tempdir() {
|
||||||
let (rd, wr) = stream();
|
let (rd, wr) = stream();
|
||||||
let f: proc() = || {
|
let f: proc() = proc() {
|
||||||
let tmp = TempDir::new("test_rm_tempdir").unwrap();
|
let tmp = TempDir::new("test_rm_tempdir").unwrap();
|
||||||
wr.send(tmp.path().clone());
|
wr.send(tmp.path().clone());
|
||||||
fail!("fail to unwind past `tmp`");
|
fail!("fail to unwind past `tmp`");
|
||||||
@@ -52,7 +52,7 @@ fn test_rm_tempdir() {
|
|||||||
let tmp = TempDir::new("test_rm_tempdir").unwrap();
|
let tmp = TempDir::new("test_rm_tempdir").unwrap();
|
||||||
let path = tmp.path().clone();
|
let path = tmp.path().clone();
|
||||||
let cell = Cell::new(tmp);
|
let cell = Cell::new(tmp);
|
||||||
let f: proc() = || {
|
let f: proc() = proc() {
|
||||||
let _tmp = cell.take();
|
let _tmp = cell.take();
|
||||||
fail!("fail to unwind past `tmp`");
|
fail!("fail to unwind past `tmp`");
|
||||||
};
|
};
|
||||||
@@ -61,7 +61,7 @@ fn test_rm_tempdir() {
|
|||||||
|
|
||||||
let path;
|
let path;
|
||||||
{
|
{
|
||||||
let f: proc() -> TempDir = || {
|
let f: proc() -> TempDir = proc() {
|
||||||
TempDir::new("test_rm_tempdir").unwrap()
|
TempDir::new("test_rm_tempdir").unwrap()
|
||||||
};
|
};
|
||||||
let tmp = task::try(f).expect("test_rm_tmdir");
|
let tmp = task::try(f).expect("test_rm_tmdir");
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ fn test_ret() { let _x: @int = return; }
|
|||||||
|
|
||||||
fn test_fail() {
|
fn test_fail() {
|
||||||
fn f() { let _x: @int = fail!(); }
|
fn f() { let _x: @int = fail!(); }
|
||||||
task::try(|| f() );
|
task::try(proc() f() );
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fail_indirect() {
|
fn test_fail_indirect() {
|
||||||
fn f() -> ! { fail!(); }
|
fn f() -> ! { fail!(); }
|
||||||
fn g() { let _x: @int = f(); }
|
fn g() { let _x: @int = f(); }
|
||||||
task::try(|| g() );
|
task::try(proc() g() );
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use std::task;
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut i = 10;
|
let mut i = 10;
|
||||||
while i > 0 { task::spawn({let i = i; || child(i)}); i = i - 1; }
|
while i > 0 { task::spawn({let i = i; proc() child(i)}); i = i - 1; }
|
||||||
info!("main thread exiting");
|
info!("main thread exiting");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct Pointy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_uniq_closure<A:Send>(a: A) -> proc() -> uint {
|
fn make_uniq_closure<A:Send>(a: A) -> proc() -> uint {
|
||||||
let result: proc() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
let result: proc() -> uint = proc() ptr::to_unsafe_ptr(&a) as uint;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ fn empty_pointy() -> @mut Pointy {
|
|||||||
return @mut Pointy {
|
return @mut Pointy {
|
||||||
a : none,
|
a : none,
|
||||||
c : ~22,
|
c : ~22,
|
||||||
d : || {},
|
d : proc() {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub fn main() {
|
|||||||
let mut expected = 0u;
|
let mut expected = 0u;
|
||||||
for i in range(0u, n) {
|
for i in range(0u, n) {
|
||||||
let ch = ch.clone();
|
let ch = ch.clone();
|
||||||
task::spawn(|| child(&ch, i) );
|
task::spawn(proc() child(&ch, i) );
|
||||||
expected += i;
|
expected += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ fn f(c: SharedChan<bool>) {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (p, c) = stream();
|
let (p, c) = stream();
|
||||||
let c = SharedChan::new(c);
|
let c = SharedChan::new(c);
|
||||||
task::spawn(|| f(c.clone()) );
|
task::spawn(proc() f(c.clone()));
|
||||||
error!("hiiiiiiiii");
|
error!("hiiiiiiiii");
|
||||||
assert!(p.recv());
|
assert!(p.recv());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user