about summary refs log tree commit diff
path: root/src/rt/sync/sync.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <mbebenita@mozilla.com>2010-09-07 23:37:51 -0700
committerMichael Bebenita <mbebenita@mozilla.com>2010-09-07 23:37:51 -0700
commit7f6d8b95bd3340ea5fa32874243dac036208105b (patch)
tree7010caf355578adc06a0919df97b0418683ba41f /src/rt/sync/sync.cpp
parentde611a309006f0976bc9a579eb1087e7a89f79a7 (diff)
downloadrust-7f6d8b95bd3340ea5fa32874243dac036208105b.tar.gz
rust-7f6d8b95bd3340ea5fa32874243dac036208105b.zip
Fixed race in the rust kernel.
Diffstat (limited to 'src/rt/sync/sync.cpp')
-rw-r--r--src/rt/sync/sync.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/rt/sync/sync.cpp b/src/rt/sync/sync.cpp
index 70e5077cf98..fdfc065249d 100644
--- a/src/rt/sync/sync.cpp
+++ b/src/rt/sync/sync.cpp
@@ -11,6 +11,10 @@ void sync::yield() {
 #endif
 }
 
+rust_thread::rust_thread() : _is_running(false) {
+    // Nop.
+}
+
 #if defined(__WIN32__)
 static DWORD WINAPI
 #elif defined(__GNUC__)
@@ -36,6 +40,7 @@ rust_thread::start() {
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    pthread_create(&thread, &attr, rust_thread_start, (void *) this);
 #endif
+   _is_running = true;
 }
 
 void
@@ -46,10 +51,10 @@ rust_thread::join() {
    pthread_join(thread, NULL);
 #endif
    thread = 0;
+   _is_running = false;
 }
 
 bool
 rust_thread::is_running() {
-    // TODO: This may be broken because of possible races.
-    return thread;
+    return _is_running;
 }