File tree Expand file tree Collapse file tree 4 files changed +18
-23
lines changed Expand file tree Collapse file tree 4 files changed +18
-23
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,6 @@ use core::to_str::ToStr;
31
31
use core:: uint;
32
32
use core:: vec;
33
33
34
- pub mod rustrt {
35
- use core:: libc:: size_t;
36
-
37
- #[ abi = "cdecl" ]
38
- pub extern {
39
- pub unsafe fn rust_sched_threads ( ) -> size_t ;
40
- }
41
- }
42
34
43
35
// The name of a test. By convention this follows the rules for rust
44
36
// paths; i.e. it should be a series of identifiers separated by double
@@ -488,11 +480,10 @@ static sched_overcommit : uint = 1;
488
480
static sched_overcommit : uint = 4u;
489
481
490
482
fn get_concurrency() -> uint {
491
- unsafe {
492
- let threads = rustrt::rust_sched_threads() as uint;
493
- if threads == 1 { 1 }
494
- else { threads * sched_overcommit }
495
- }
483
+ use core::rt;
484
+ let threads = rt::util::default_sched_threads();
485
+ if threads == 1 { 1 }
486
+ else { threads * sched_overcommit }
496
487
}
497
488
498
489
#[allow(non_implicitly_copyable_typarams)]
Original file line number Diff line number Diff line change @@ -63,11 +63,9 @@ Several modules in `core` are clients of `rt`:
63
63
use cell:: Cell ;
64
64
use clone:: Clone ;
65
65
use container:: Container ;
66
- use from_str:: FromStr ;
67
66
use iter:: Times ;
68
67
use iterator:: IteratorUtil ;
69
- use option:: { Some , None } ;
70
- use os;
68
+ use option:: Some ;
71
69
use ptr:: RawPtr ;
72
70
use rt:: sched:: { Scheduler , Coroutine , Shutdown } ;
73
71
use rt:: sleeper_list:: SleeperList ;
@@ -223,10 +221,7 @@ pub fn run(main: ~fn()) -> int {
223
221
224
222
static DEFAULT_ERROR_CODE : int = 101 ;
225
223
226
- let nthreads = match os:: getenv ( "RUST_THREADS" ) {
227
- Some ( nstr) => FromStr :: from_str ( nstr) . get ( ) ,
228
- None => util:: num_cpus ( )
229
- } ;
224
+ let nthreads = util:: default_sched_threads ( ) ;
230
225
231
226
// The shared list of sleeping schedulers. Schedulers wake each other
232
227
// occassionally to do new work.
Original file line number Diff line number Diff line change 9
9
// except according to those terms.
10
10
11
11
use container:: Container ;
12
+ use from_str:: FromStr ;
12
13
use iterator:: IteratorUtil ;
13
14
use libc;
15
+ use option:: { Some , None } ;
16
+ use os;
14
17
use str:: StrSlice ;
15
18
16
19
/// Get the number of cores available
@@ -24,6 +27,15 @@ pub fn num_cpus() -> uint {
24
27
}
25
28
}
26
29
30
+ /// Get's the number of scheduler threads requested by the environment
31
+ /// either `RUST_THREADS` or `num_cpus`.
32
+ pub fn default_sched_threads ( ) -> uint {
33
+ match os:: getenv ( "RUST_THREADS" ) {
34
+ Some ( nstr) => FromStr :: from_str ( nstr) . get ( ) ,
35
+ None => num_cpus ( )
36
+ }
37
+ }
38
+
27
39
pub fn dumb_println ( s : & str ) {
28
40
use io:: WriterUtil ;
29
41
let dbg = :: libc:: STDERR_FILENO as :: io:: fd_t ;
Original file line number Diff line number Diff line change @@ -23,15 +23,13 @@ mod rustrt {
23
23
pub fn rust_get_sched_id ( ) -> libc:: intptr_t ;
24
24
pub fn rust_get_argc ( ) -> libc:: c_int ;
25
25
pub fn get_task_id ( ) -> libc:: intptr_t ;
26
- pub fn rust_sched_threads ( ) ;
27
26
pub fn rust_get_task ( ) ;
28
27
}
29
28
}
30
29
31
30
fn calllink01 ( ) { unsafe { rustrt:: rust_get_sched_id ( ) ; } }
32
31
fn calllink02 ( ) { unsafe { rustrt:: rust_get_argc ( ) ; } }
33
32
fn calllink08 ( ) { unsafe { rustrt:: get_task_id ( ) ; } }
34
- fn calllink09 ( ) { unsafe { rustrt:: rust_sched_threads ( ) ; } }
35
33
fn calllink10 ( ) { unsafe { rustrt:: rust_get_task ( ) ; } }
36
34
37
35
fn runtest ( f : extern fn ( ) , frame_backoff : u32 ) {
@@ -64,7 +62,6 @@ pub fn main() {
64
62
calllink01,
65
63
calllink02,
66
64
calllink08,
67
- calllink09,
68
65
calllink10
69
66
] ;
70
67
let mut rng = rand:: rng ( ) ;
You can’t perform that action at this time.
0 commit comments