about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-25 18:00:37 -0700
committerEric Holk <eholk@mozilla.com>2011-07-28 10:47:28 -0700
commit5302cde188bba80dd38c58eaafa792d621b0818c (patch)
tree663ca3e81a7254548e756ea0dfef66d4362f971a /src/rt/rust_kernel.cpp
parente697a52359874c2b7387be96e664b1f94b14255b (diff)
downloadrust-5302cde188bba80dd38c58eaafa792d621b0818c.tar.gz
rust-5302cde188bba80dd38c58eaafa792d621b0818c.zip
Made task threads wait instead of sleep, so they can be woken up. This appears to give us much better parallel performance.
Also, commented out one more unsafe log and updated rust_kernel.cpp to compile under g++
Diffstat (limited to 'src/rt/rust_kernel.cpp')
-rw-r--r--src/rt/rust_kernel.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 1eb82602798..9cdf07cd759 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -53,13 +53,13 @@ rust_kernel::destroy_scheduler(rust_scheduler *sched) {
 }
 
 void rust_kernel::create_schedulers() {
-    for(int i = 0; i < num_threads; ++i) {
+    for(size_t i = 0; i < num_threads; ++i) {
         threads.push(create_scheduler(i));
     }
 }
 
 void rust_kernel::destroy_schedulers() {
-    for(int i = 0; i < num_threads; ++i) {
+    for(size_t i = 0; i < num_threads; ++i) {
         destroy_scheduler(threads[i]);
     }
 }
@@ -106,7 +106,7 @@ rust_kernel::get_port_handle(rust_port *port) {
 
 void
 rust_kernel::log_all_scheduler_state() {
-    for(int i = 0; i < num_threads; ++i) {
+    for(size_t i = 0; i < num_threads; ++i) {
         threads[i]->log_state();
     }
 }
@@ -252,12 +252,12 @@ rust_kernel::signal_kernel_lock() {
 
 int rust_kernel::start_task_threads()
 {
-    for(int i = 0; i < num_threads; ++i) {
+    for(size_t i = 0; i < num_threads; ++i) {
         rust_scheduler *thread = threads[i];
         thread->start();
     }
 
-    for(int i = 0; i < num_threads; ++i) {
+    for(size_t i = 0; i < num_threads; ++i) {
         rust_scheduler *thread = threads[i];
         thread->join();
     }
@@ -271,6 +271,12 @@ rust_kernel::create_task(rust_task *spawner, const char *name) {
     return threads[rand(&rctx) % num_threads]->create_task(spawner, name);
 }
 
+void rust_kernel::wakeup_schedulers() {
+    for(size_t i = 0; i < num_threads; ++i) {
+        threads[i]->lock.signal_all();
+    }
+}
+
 #ifdef __WIN32__
 void
 rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {