File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
branches/try2/src/libstd/rt Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: f9a5005f52d528797d6b98a3bee73ab2d71b9aa3
8
+ refs/heads/try2: 8afec77cb07394c5f2d54dcc0ebe075fc304efb7
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -59,21 +59,32 @@ pub fn run_in_newsched_task(f: ~fn()) {
59
59
/// in one of the schedulers. The schedulers will stay alive
60
60
/// until the function `f` returns.
61
61
pub fn run_in_mt_newsched_task ( f : ~fn ( ) ) {
62
+ use libc;
63
+ use os;
64
+ use from_str:: FromStr ;
62
65
use rt:: uv:: uvio:: UvEventLoop ;
63
66
use rt:: sched:: Shutdown ;
64
67
65
68
let f_cell = Cell ( f) ;
66
69
67
70
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
+ } ;
69
80
70
81
let sleepers = SleeperList :: new ( ) ;
71
82
let work_queue = WorkQueue :: new ( ) ;
72
83
73
84
let mut handles = ~[ ] ;
74
85
let mut scheds = ~[ ] ;
75
86
76
- for uint:: range( 0 , N ) |_| {
87
+ for uint:: range( 0 , nthreads ) |_| {
77
88
let loop_ = ~UvEventLoop :: new ( ) ;
78
89
let mut sched = ~Scheduler :: new ( loop_, work_queue. clone ( ) , sleepers. clone ( ) ) ;
79
90
let handle = sched. make_handle ( ) ;
@@ -111,6 +122,10 @@ pub fn run_in_mt_newsched_task(f: ~fn()) {
111
122
// Wait for schedulers
112
123
let _threads = threads;
113
124
}
125
+
126
+ extern {
127
+ fn rust_get_num_cpus ( ) -> libc:: uintptr_t ;
128
+ }
114
129
}
115
130
116
131
/// Test tasks will abort on failure instead of unwinding
You can’t perform that action at this time.
0 commit comments