PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/spawn-fn.rs

http://github.com/jruderman/rust
Rust | 18 lines | 14 code | 3 blank | 1 comment | 1 complexity | 850dc4b373c2c3fa4d83819b1b5fb439 MD5 | raw file
 1// -*- rust -*-
 2
 3use std;
 4import task::yield;
 5import task;
 6
 7fn x(s: ~str, n: int) {
 8    log(debug, s);
 9    log(debug, n);
10}
11
12fn main() {
13    task::spawn(|| x(~"hello from first spawned fn", 65) );
14    task::spawn(|| x(~"hello from second spawned fn", 66) );
15    task::spawn(|| x(~"hello from third spawned fn", 67) );
16    let mut i: int = 30;
17    while i > 0 { i = i - 1; debug!{"parent sleeping"}; yield(); }
18}