Skip to content

Commit a9b8f72

Browse files
committed
Remove __pthread_detached_exit in favor of __emscripten_thread_cleanup. NFC.
1 parent dfc1d98 commit a9b8f72

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 (d.target === 'setimmediate') {
284279
// Worker wants to postMessage() to itself to implement setImmediate()
285280
// emulation.
@@ -307,7 +302,7 @@ var LibraryPThread = {
307302
worker.on('error', function(e) {
308303
worker.onerror(e);
309304
});
310-
worker.on('detachedExit', function() {
305+
worker.on('exit', function() {
311306
// TODO: update the worker queue?
312307
// See: https://github.com/emscripten-core/emscripten/issues/9763
313308
});
@@ -816,12 +811,6 @@ var LibraryPThread = {
816811
return 0;
817812
},
818813

819-
__pthread_detached_exit: function() {
820-
// Called at the end of pthread_exit (which occurs also when leaving the
821-
// thread main function) if an only if the thread is in a detached state.
822-
postMessage({ 'cmd': 'detachedExit' });
823-
},
824-
825814
// Returns 0 on success, or one of the values -ETIMEDOUT, -EWOULDBLOCK or -EINVAL on error.
826815
emscripten_futex_wait__deps: ['emscripten_main_thread_process_queued_calls'],
827816
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(pthread_t 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)