diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-02-07 17:43:54 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-08 15:42:51 -0800 |
| commit | 2f4e7c157eb3ab9cd8270c3e9fffedd03f0cb055 (patch) | |
| tree | c7d792cd47cf1ea8c0f67aea22b69e34eb35a960 /src/rt/rust_builtin.cpp | |
| parent | f2a1aa2649ad030f189c54245ee182a0aa6983ed (diff) | |
| download | rust-2f4e7c157eb3ab9cd8270c3e9fffedd03f0cb055.tar.gz rust-2f4e7c157eb3ab9cd8270c3e9fffedd03f0cb055.zip | |
rt: Export a scheduler API
Diffstat (limited to 'src/rt/rust_builtin.cpp')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 76f80192e89..53093190efe 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -431,16 +431,43 @@ nano_time(uint64_t *ns) { *ns = t.time_ns(); } +extern "C" CDECL rust_sched_id +rust_get_sched_id() { + rust_task *task = rust_task_thread::get_task(); + return task->sched->get_id(); +} + +extern "C" CDECL rust_sched_id +rust_new_sched(size_t threads) { + rust_task *task = rust_task_thread::get_task(); + A(task->thread, threads > 0, + "Can't create a scheduler with no threads, silly!"); + return task->kernel->create_scheduler(threads); +} + extern "C" CDECL rust_task_id get_task_id() { rust_task *task = rust_task_thread::get_task(); return task->user.id; } +static rust_task_id +new_task_common(rust_scheduler *sched, rust_task *parent) { + return sched->create_task(parent, NULL); +} + extern "C" CDECL rust_task_id new_task() { rust_task *task = rust_task_thread::get_task(); - return task->sched->create_task(task, NULL); + return new_task_common(task->sched, task); +} + +extern "C" CDECL rust_task_id +rust_new_task_in_sched(rust_sched_id id) { + rust_task *task = rust_task_thread::get_task(); + rust_scheduler *sched = task->kernel->get_scheduler_by_id(id); + // FIXME: What if we didn't get the scheduler? + return new_task_common(sched, task); } extern "C" CDECL void |
