Skip to content

Commit 4029798

Browse files
committed
---
yaml --- r: 8183 b: refs/heads/snap-stage3 c: 81e1564 h: refs/heads/master i: 8181: 3b557ea 8179: 7065290 8175: 0928410 v: v3
1 parent 5186511 commit 4029798

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
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 5d8d591ffc110836a12487ac53a120b2015856ce
4+
refs/heads/snap-stage3: 81e1564a7d6097164ff914eb7e341f9fca42f1df
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/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/snap-stage3/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/snap-stage3/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)