Skip to content

Commit 57f1d43

Browse files
committed
---
yaml --- r: 14169 b: refs/heads/try c: 81e1564 h: refs/heads/master i: 14167: 8fe8b51 v: v3
1 parent 5eb4869 commit 57f1d43

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 5d8d591ffc110836a12487ac53a120b2015856ce
5+
refs/heads/try: 81e1564a7d6097164ff914eb7e341f9fca42f1df
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_task_thread.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ rust_task_thread::create_task(rust_task *spawner, const char *name,
319319

320320
void rust_task_thread::run() {
321321
this->start_main_loop();
322+
detach();
322323
sched->release_task_thread();
323324
}
324325

branches/try/src/rt/sync/rust_thread.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
rust_thread::rust_thread() : thread(0) {
55
}
66

7+
rust_thread::~rust_thread() {
8+
}
9+
710
#if defined(__WIN32__)
811
static DWORD WINAPI
912
#elif defined(__GNUC__)
@@ -41,3 +44,12 @@ rust_thread::join() {
4144
#endif
4245
thread = 0;
4346
}
47+
48+
void
49+
rust_thread::detach() {
50+
#if !defined(__WIN32__)
51+
// Don't leak pthread resources.
52+
// http://crosstantine.blogspot.com/2010/01/pthreadcreate-memory-leak.html
53+
pthread_detach(thread);
54+
#endif
55+
}

branches/try/src/rt/sync/rust_thread.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ class rust_thread {
1212
pthread_t thread;
1313
#endif
1414
rust_thread();
15+
virtual ~rust_thread();
16+
1517
void start();
1618

1719
virtual void run() {
1820
return;
1921
}
2022

2123
void join();
22-
23-
virtual ~rust_thread() {} // quiet the compiler
24+
void detach();
2425
};
2526

2627
#endif /* RUST_THREAD_H */

0 commit comments

Comments
 (0)