Skip to content

Commit 82143d1

Browse files
committed
---
yaml --- r: 142601 b: refs/heads/try2 c: 8afec77 h: refs/heads/master i: 142599: 087a9dd v: v3
1 parent 9b8b888 commit 82143d1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f9a5005f52d528797d6b98a3bee73ab2d71b9aa3
8+
refs/heads/try2: 8afec77cb07394c5f2d54dcc0ebe075fc304efb7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/rt/test.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,32 @@ pub fn run_in_newsched_task(f: ~fn()) {
5959
/// in one of the schedulers. The schedulers will stay alive
6060
/// until the function `f` returns.
6161
pub fn run_in_mt_newsched_task(f: ~fn()) {
62+
use libc;
63+
use os;
64+
use from_str::FromStr;
6265
use rt::uv::uvio::UvEventLoop;
6366
use rt::sched::Shutdown;
6467

6568
let f_cell = Cell(f);
6669

6770
do run_in_bare_thread {
68-
static N: uint = 4;
71+
let nthreads = match os::getenv("RUST_TEST_THREADS") {
72+
Some(nstr) => FromStr::from_str(nstr).get(),
73+
None => unsafe {
74+
// Using more threads than cores in test code
75+
// to force the OS to preempt them frequently.
76+
// Assuming that this help stress test concurrent types.
77+
rust_get_num_cpus() * 2
78+
}
79+
};
6980

7081
let sleepers = SleeperList::new();
7182
let work_queue = WorkQueue::new();
7283

7384
let mut handles = ~[];
7485
let mut scheds = ~[];
7586

76-
for uint::range(0, N) |_| {
87+
for uint::range(0, nthreads) |_| {
7788
let loop_ = ~UvEventLoop::new();
7889
let mut sched = ~Scheduler::new(loop_, work_queue.clone(), sleepers.clone());
7990
let handle = sched.make_handle();
@@ -111,6 +122,10 @@ pub fn run_in_mt_newsched_task(f: ~fn()) {
111122
// Wait for schedulers
112123
let _threads = threads;
113124
}
125+
126+
extern {
127+
fn rust_get_num_cpus() -> libc::uintptr_t;
128+
}
114129
}
115130

116131
/// Test tasks will abort on failure instead of unwinding

0 commit comments

Comments
 (0)