Skip to content

Commit 7c966c2

Browse files
committed
Remove __pthread_detached_exit in favor of __emscripten_thread_cleanup. NFC.
1 parent 23d85b1 commit 7c966c2

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

src/library_pthread.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ var LibraryPThread = {
275275
err('Thread ' + d['threadId'] + ': ' + d['text']);
276276
} else if (cmd === 'alert') {
277277
alert('Thread ' + d['threadId'] + ': ' + d['text']);
278-
} else if (cmd === 'detachedExit') {
279-
#if ASSERTIONS
280-
assert(worker.pthread);
281-
#endif
282-
PThread.returnWorkerToPool(worker);
283278
} else if (cmd === 'cancelDone') {
284279
PThread.returnWorkerToPool(worker);
285280
} else if (d.target === 'setimmediate') {
@@ -309,7 +304,7 @@ var LibraryPThread = {
309304
worker.on('error', function(e) {
310305
worker.onerror(e);
311306
});
312-
worker.on('detachedExit', function() {
307+
worker.on('exit', function() {
313308
// TODO: update the worker queue?
314309
// See: https://github.com/emscripten-core/emscripten/issues/9763
315310
});
@@ -838,12 +833,6 @@ var LibraryPThread = {
838833
return 0;
839834
},
840835

841-
__pthread_detached_exit: function() {
842-
// Called at the end of pthread_exit (which occurs also when leaving the
843-
// thread main function) if an only if the thread is in a detached state.
844-
postMessage({ 'cmd': 'detachedExit' });
845-
},
846-
847836
// Returns 0 on success, or one of the values -ETIMEDOUT, -EWOULDBLOCK or -EINVAL on error.
848837
emscripten_futex_wait__deps: ['emscripten_main_thread_process_queued_calls'],
849838
emscripten_futex_wait: function(addr, val, timeout) {

system/lib/pthread/pthread_create.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
extern int __pthread_create_js(struct pthread *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
2626
extern void _emscripten_thread_init(int, int, int);
2727
extern int _emscripten_default_pthread_stack_size();
28-
extern void __pthread_detached_exit();
28+
extern void __emscripten_thread_cleanup(pthread_t thread);
2929
extern void* _emscripten_tls_base();
3030
extern int8_t __dso_handle;
3131

@@ -236,7 +236,7 @@ void _emscripten_thread_exit(void* result) {
236236
// object and we are done.
237237
if (state == DT_DETACHED) {
238238
self->detach_state = DT_EXITED;
239-
__pthread_detached_exit();
239+
__emscripten_thread_cleanup(self);
240240
} else {
241241
self->detach_state = DT_EXITING;
242242
// wake any threads that might be waiting for us to exit

0 commit comments

Comments
 (0)