2012-12-11 01:32:48 +00:00
|
|
|
// Copyright 2012 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.
|
|
|
|
|
2011-08-31 11:22:58 +00:00
|
|
|
// xfail-test
|
2010-06-24 04:03:09 +00:00
|
|
|
// This checks that preemption works.
|
|
|
|
|
2013-06-22 18:43:15 +00:00
|
|
|
// note: halfway done porting to modern rust
|
|
|
|
extern mod extra;
|
|
|
|
|
|
|
|
use std::comm;
|
|
|
|
use extra::comm;
|
|
|
|
|
|
|
|
fn starve_main(alive: Port<int>) {
|
2013-07-16 17:08:08 +00:00
|
|
|
info!("signalling main");
|
2013-06-22 18:43:15 +00:00
|
|
|
alive.recv();
|
2013-07-16 17:08:08 +00:00
|
|
|
info!("starving main");
|
2013-06-22 18:43:15 +00:00
|
|
|
let mut i: int = 0;
|
2012-03-10 00:11:56 +00:00
|
|
|
loop { i += 1; }
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-06-22 18:43:15 +00:00
|
|
|
let (port, chan) = stream();
|
|
|
|
|
2013-07-16 17:08:08 +00:00
|
|
|
info!("main started");
|
2013-06-22 18:43:15 +00:00
|
|
|
do spawn {
|
|
|
|
starve_main(port);
|
2013-04-18 22:13:24 +00:00
|
|
|
};
|
2013-06-22 18:43:15 +00:00
|
|
|
let mut i: int = 0;
|
2013-07-16 17:08:08 +00:00
|
|
|
info!("main waiting for alive signal");
|
2013-06-22 18:43:15 +00:00
|
|
|
chan.send(i);
|
2013-07-16 17:08:08 +00:00
|
|
|
info!("main got alive signal");
|
|
|
|
while i < 50 { info!("main iterated"); i += 1; }
|
|
|
|
info!("main completed");
|
2011-08-10 16:27:22 +00:00
|
|
|
}
|