Skip to content

Commit 8e2c8b2

Browse files
committed
---
yaml --- r: 30523 b: refs/heads/incoming c: 6f9539a h: refs/heads/master i: 30521: 8f16eba 30519: 0ae2038 v: v3
1 parent 1a0e532 commit 8e2c8b2

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: b776395263bfc9908d8fec80d7d1d0f67b8490e8
9+
refs/heads/incoming: 6f9539a15c4f09dfa296d5f815ca341af1345382
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/task.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
14031403

14041404
let num_threads = match opts.mode {
14051405
SingleThreaded => 1u,
1406-
ThreadPerCore => {
1407-
fail ~"thread_per_core scheduling mode unimplemented"
1408-
}
1406+
ThreadPerCore => rustrt::rust_num_threads(),
14091407
ThreadPerTask => {
1410-
fail ~"thread_per_task scheduling mode unimplemented"
1408+
fail ~"ThreadPerTask scheduling mode unimplemented"
14111409
}
14121410
ManualThreads(threads) => {
14131411
if threads == 0u {
@@ -1657,6 +1655,8 @@ extern mod rustrt {
16571655

16581656
fn rust_get_sched_id() -> sched_id;
16591657
fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id;
1658+
fn sched_threads() -> libc::size_t;
1659+
fn rust_num_threads() -> libc::uintptr_t;
16601660

16611661
fn get_task_id() -> task_id;
16621662
#[rust_stack]
@@ -2422,3 +2422,13 @@ fn test_tls_cleanup_on_failure() unsafe {
24222422
local_data_set(int_key, @31337);
24232423
fail;
24242424
}
2425+
2426+
#[test]
2427+
fn test_sched_thread_per_core() {
2428+
let cores = rustrt::rust_num_threads();
2429+
let mut reported_threads = 0u;
2430+
do spawn_sched(ThreadPerCore) {
2431+
reported_threads = rustrt::sched_threads();
2432+
}
2433+
assert(cores == reported_threads);
2434+
}

branches/incoming/src/rt/rust_builtin.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ rust_get_sched_id() {
572572
return task->sched->get_id();
573573
}
574574

575+
extern "C" CDECL uintptr_t
576+
rust_num_threads() {
577+
rust_task *task = rust_get_current_task();
578+
return task->kernel->env->num_sched_threads;
579+
}
580+
575581
extern "C" CDECL rust_sched_id
576582
rust_new_sched(uintptr_t threads) {
577583
rust_task *task = rust_get_current_task();
@@ -620,7 +626,7 @@ start_task(rust_task *target, fn_env_pair *f) {
620626
target->start(f->f, f->env, NULL);
621627
}
622628

623-
extern "C" CDECL int
629+
extern "C" CDECL size_t
624630
sched_threads() {
625631
rust_task *task = rust_get_current_task();
626632
return task->sched->number_of_threads();

branches/incoming/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ rand_seed
3232
rust_get_sched_id
3333
rust_new_sched
3434
rust_new_task_in_sched
35+
rust_num_threads
3536
rust_path_is_dir
3637
rust_path_exists
3738
rust_getcwd

0 commit comments

Comments
 (0)