about summary refs log tree commit diff
path: root/src/rt/sync/sync.cpp
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-09-08 19:13:49 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-09-08 19:13:49 -0700
commit616b7afb724a32df41eebfaf95402d008c60b411 (patch)
tree03e13578e8b43b9001cef983d1117800a6f93e65 /src/rt/sync/sync.cpp
parent13d6f874316c9f69ab3a29f120ce410da2290a64 (diff)
downloadrust-616b7afb724a32df41eebfaf95402d008c60b411.tar.gz
rust-616b7afb724a32df41eebfaf95402d008c60b411.zip
Tidy up the sync dir, remove dead or mis-designed code in favour of OS primitives, switch rust_kernel to use a lock/signal pair and wait rather than spin.
Diffstat (limited to 'src/rt/sync/sync.cpp')
-rw-r--r--src/rt/sync/sync.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rt/sync/sync.cpp b/src/rt/sync/sync.cpp
index fdfc065249d..c754392aece 100644
--- a/src/rt/sync/sync.cpp
+++ b/src/rt/sync/sync.cpp
@@ -11,7 +11,7 @@ void sync::yield() {
 #endif
 }
 
-rust_thread::rust_thread() : _is_running(false) {
+rust_thread::rust_thread() : _is_running(false), thread(0) {
     // Nop.
 }
 
@@ -25,7 +25,6 @@ static void *
 rust_thread_start(void *ptr) {
     rust_thread *thread = (rust_thread *) ptr;
     thread->run();
-    thread->thread = 0;
     return 0;
 }
 
@@ -46,9 +45,11 @@ rust_thread::start() {
 void
 rust_thread::join() {
 #if defined(__WIN32__)
-   WaitForSingleObject(thread, INFINITE);
+   if (thread)
+     WaitForSingleObject(thread, INFINITE);
 #else
-   pthread_join(thread, NULL);
+   if (thread)
+     pthread_join(thread, NULL);
 #endif
    thread = 0;
    _is_running = false;