extra: Make test runner compatible with newsched

This commit is contained in:
Brian Anderson 2013-06-23 18:22:57 -07:00
parent d071f51cdc
commit e65d0cbabe
4 changed files with 18 additions and 23 deletions

View file

@ -63,11 +63,9 @@ Several modules in `core` are clients of `rt`:
use cell::Cell;
use clone::Clone;
use container::Container;
use from_str::FromStr;
use iter::Times;
use iterator::IteratorUtil;
use option::{Some, None};
use os;
use option::Some;
use ptr::RawPtr;
use rt::sched::{Scheduler, Coroutine, Shutdown};
use rt::sleeper_list::SleeperList;
@ -223,10 +221,7 @@ pub fn run(main: ~fn()) -> int {
static DEFAULT_ERROR_CODE: int = 101;
let nthreads = match os::getenv("RUST_THREADS") {
Some(nstr) => FromStr::from_str(nstr).get(),
None => util::num_cpus()
};
let nthreads = util::default_sched_threads();
// The shared list of sleeping schedulers. Schedulers wake each other
// occassionally to do new work.

View file

@ -9,8 +9,11 @@
// except according to those terms.
use container::Container;
use from_str::FromStr;
use iterator::IteratorUtil;
use libc;
use option::{Some, None};
use os;
use str::StrSlice;
/// Get the number of cores available
@ -24,6 +27,15 @@ pub fn num_cpus() -> uint {
}
}
/// Get's the number of scheduler threads requested by the environment
/// either `RUST_THREADS` or `num_cpus`.
pub fn default_sched_threads() -> uint {
match os::getenv("RUST_THREADS") {
Some(nstr) => FromStr::from_str(nstr).get(),
None => num_cpus()
}
}
pub fn dumb_println(s: &str) {
use io::WriterUtil;
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;