about summary refs log tree commit diff
path: root/src/rt/sync/rust_thread.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-09 16:13:56 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-09 19:00:16 -0800
commit81e1564a7d6097164ff914eb7e341f9fca42f1df (patch)
tree7f2d454cfea9780c71993c73dd2ea8e60722a6a5 /src/rt/sync/rust_thread.cpp
parent5d8d591ffc110836a12487ac53a120b2015856ce (diff)
downloadrust-81e1564a7d6097164ff914eb7e341f9fca42f1df.tar.gz
rust-81e1564a7d6097164ff914eb7e341f9fca42f1df.zip
rt: Detach pthreads before exiting
Joinable pthreads need to be either joined or detached and we no
longer join with the scheduler threads.
Diffstat (limited to 'src/rt/sync/rust_thread.cpp')
-rw-r--r--src/rt/sync/rust_thread.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rt/sync/rust_thread.cpp b/src/rt/sync/rust_thread.cpp
index 49daaa5c96d..3c54fdcf3f4 100644
--- a/src/rt/sync/rust_thread.cpp
+++ b/src/rt/sync/rust_thread.cpp
@@ -4,6 +4,9 @@
 rust_thread::rust_thread() : thread(0) {
 }
 
+rust_thread::~rust_thread() {
+}
+
 #if defined(__WIN32__)
 static DWORD WINAPI
 #elif defined(__GNUC__)
@@ -41,3 +44,12 @@ rust_thread::join() {
 #endif
    thread = 0;
 }
+
+void
+rust_thread::detach() {
+#if !defined(__WIN32__)
+    // Don't leak pthread resources.
+    // http://crosstantine.blogspot.com/2010/01/pthreadcreate-memory-leak.html
+    pthread_detach(thread);
+#endif
+}