diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-03-29 15:21:32 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-03-31 19:51:29 -0700 |
| commit | 6bf8d19712e2310ab6a7da2e82b2287278a772e4 (patch) | |
| tree | c57072780959c41cd02b9b2f48d003b89ddb9632 /src/rt/rust_scheduler.cpp | |
| parent | 620b4d4946dbaf41ec8c0c7f9ba5c5d9810db89b (diff) | |
| download | rust-6bf8d19712e2310ab6a7da2e82b2287278a772e4.tar.gz rust-6bf8d19712e2310ab6a7da2e82b2287278a772e4.zip | |
rt: Extract rust_sched_launcher from rust_task_thread
rust_sched_launcher is actually responsible for setting up the thread and starting the loop. There will be other implementations that do not actually set up a new thread, in order to support scheduling tasks on the main OS thread.
Diffstat (limited to 'src/rt/rust_scheduler.cpp')
| -rw-r--r-- | src/rt/rust_scheduler.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 482739ded99..4153972f83a 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -1,5 +1,6 @@ #include "rust_scheduler.h" #include "rust_util.h" +#include "rust_sched_launcher.h" rust_scheduler::rust_scheduler(rust_kernel *kernel, rust_srv *srv, @@ -21,21 +22,20 @@ rust_scheduler::~rust_scheduler() { destroy_task_threads(); } -rust_task_thread * +rust_sched_launcher * rust_scheduler::create_task_thread(int id) { rust_srv *srv = this->srv->clone(); - rust_task_thread *thread = - new (kernel, "rust_task_thread") rust_task_thread(this, srv, id); - KLOG(kernel, kern, "created task thread: " PTR ", id: %d, index: %d", - thread, id, thread->list_index); + rust_sched_launcher *thread = + new (kernel, "rust_sched_launcher") rust_sched_launcher(this, srv, id); + KLOG(kernel, kern, "created task thread: " PTR ", id: %d", + thread, id); return thread; } void -rust_scheduler::destroy_task_thread(rust_task_thread *thread) { - KLOG(kernel, kern, "deleting task thread: " PTR ", name: %s, index: %d", - thread, thread->name, thread->list_index); - rust_srv *srv = thread->srv; +rust_scheduler::destroy_task_thread(rust_sched_launcher *thread) { + KLOG(kernel, kern, "deleting task thread: " PTR, thread); + rust_srv *srv = thread->get_loop()->srv; delete thread; delete srv; } @@ -60,7 +60,7 @@ void rust_scheduler::start_task_threads() { for(size_t i = 0; i < num_threads; ++i) { - rust_task_thread *thread = threads[i]; + rust_sched_launcher *thread = threads[i]; thread->start(); } } @@ -69,7 +69,7 @@ void rust_scheduler::join_task_threads() { for(size_t i = 0; i < num_threads; ++i) { - rust_task_thread *thread = threads[i]; + rust_sched_launcher *thread = threads[i]; thread->join(); } } @@ -77,8 +77,8 @@ rust_scheduler::join_task_threads() void rust_scheduler::kill_all_tasks() { for(size_t i = 0; i < num_threads; ++i) { - rust_task_thread *thread = threads[i]; - thread->kill_all_tasks(); + rust_sched_launcher *thread = threads[i]; + thread->get_loop()->kill_all_tasks(); } } @@ -92,8 +92,8 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) { if (cur_thread >= num_threads) cur_thread = 0; } - rust_task_thread *thread = threads[thread_no]; - return thread->create_task(spawner, name); + rust_sched_launcher *thread = threads[thread_no]; + return thread->get_loop()->create_task(spawner, name); } void @@ -118,7 +118,7 @@ rust_scheduler::exit() { // scheduler will get destroyed, and our fields will cease to exist. size_t current_num_threads = num_threads; for(size_t i = 0; i < current_num_threads; ++i) { - threads[i]->exit(); + threads[i]->get_loop()->exit(); } } |
