Skip to content

Commit 97d4676

Browse files
authored
Remove __pthread_detached_exit in favor of __emscripten_thread_cleanup. NFC. (#15605)
1 parent ac54c94 commit 97d4676

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

src/library_pthread.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,6 @@ var LibraryPThread = {
233233
err('Thread ' + d['threadId'] + ': ' + d['text']);
234234
} else if (cmd === 'alert') {
235235
alert('Thread ' + d['threadId'] + ': ' + d['text']);
236-
} else if (cmd === 'detachedExit') {
237-
#if ASSERTIONS
238-
assert(worker.pthread);
239-
#endif
240-
PThread.returnWorkerToPool(worker);
241236
} else if (d.target === 'setimmediate') {
242237
// Worker wants to postMessage() to itself to implement setImmediate()
243238
// emulation.
@@ -802,12 +797,6 @@ var LibraryPThread = {
802797
return 0;
803798
},
804799

805-
__pthread_detached_exit: function() {
806-
// Called at the end of pthread_exit (which occurs also when leaving the
807-
// thread main function) if an only if the thread is in a detached state.
808-
postMessage({ 'cmd': 'detachedExit' });
809-
},
810-
811800
// Returns 0 on success, or one of the values -ETIMEDOUT, -EWOULDBLOCK or -EINVAL on error.
812801
_emscripten_futex_wait_non_blocking__deps: ['emscripten_main_thread_process_queued_calls'],
813802
_emscripten_futex_wait_non_blocking: 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 __set_thread_state(pthread_t ptr, int is_main, int is_runtime, int can_block);
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

@@ -242,7 +242,7 @@ void _emscripten_thread_exit(void* result) {
242242
// object and we are done.
243243
if (state == DT_DETACHED) {
244244
self->detach_state = DT_EXITED;
245-
__pthread_detached_exit();
245+
__emscripten_thread_cleanup(self);
246246
} else {
247247
self->detach_state = DT_EXITING;
248248
// wake any threads that might be waiting for us to exit

system/lib/pthread/pthread_join.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <pthread.h>
1111

1212
extern int __pthread_join_js(pthread_t t, void **res, int tryjoin);
13-
extern int __emscripten_thread_cleanup(pthread_t t);
13+
extern void __emscripten_thread_cleanup(pthread_t t);
1414

1515
static int __pthread_join_internal(pthread_t t, void **res) {
1616
if (t->self != t) {

0 commit comments

Comments
 (0)