diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-06-24 16:50:06 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-06-28 16:12:33 -0700 |
| commit | f6f945fed5c8d1061d80b444331910df29afa392 (patch) | |
| tree | 1ee8908830878e916d26cbae145b00771d5c9c9d /src/rt/rust_kernel.cpp | |
| parent | c6d83248301b4aed366b9bef682d200381324c01 (diff) | |
| download | rust-f6f945fed5c8d1061d80b444331910df29afa392.tar.gz rust-f6f945fed5c8d1061d80b444331910df29afa392.zip | |
Moved thread management to rust_kernel.
Diffstat (limited to 'src/rt/rust_kernel.cpp')
| -rw-r--r-- | src/rt/rust_kernel.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 9af5f9e2b41..5e495b8c822 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -224,6 +224,37 @@ rust_kernel::signal_kernel_lock() { _kernel_lock.unlock(); } +int rust_kernel::start_task_threads(int num_threads) +{ + rust_task_thread *thread = NULL; + + // -1, because this thread will also be a thread. + for(int i = 0; i < num_threads - 1; ++i) { + thread = new rust_task_thread(i + 1, this); + thread->start(); + threads.push(thread); + } + + dom->start_main_loop(0); + + while(threads.pop(&thread)) { + thread->join(); + delete thread; + } + + return dom->rval; +} + +rust_task_thread::rust_task_thread(int id, rust_kernel *owner) + : id(id), owner(owner) +{ +} + +void rust_task_thread::run() +{ + owner->dom->start_main_loop(id); +} + // // Local Variables: // mode: C++ |
