Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ var LibraryPThread = {
#endif
if ({{{ ENVIRONMENT_IS_MAIN_THREAD() }}}) {
PThread.initMainThread();
} else {
PThread.initWorker();
}
},
initMainThread() {
Expand All @@ -122,19 +120,6 @@ var LibraryPThread = {
#endif
},

initWorker() {
#if isSymbolNeeded('$noExitRuntime')
// The default behaviour for pthreads is always to exit once they return
// from their entry point (or call pthread_exit). If we set noExitRuntime
// to true here on pthreads they would never complete and attempt to
// pthread_join to them would block forever.
// pthreads can still choose to set `noExitRuntime` explicitly, or
// call emscripten_unwind_to_js_event_loop to extend their lifetime beyond
// their main function. See comment in src/runtime_pthread.js for more.
noExitRuntime = false;
#endif
},

#if PTHREADS_PROFILING
getThreadName(pthreadPtr) {
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, '*') }}};
Expand Down Expand Up @@ -1066,6 +1051,16 @@ var LibraryPThread = {
// `runtimeKeepaliveCounter` to zero. Reset it now so the new thread won't
// be affected.
runtimeKeepaliveCounter = 0;

#if isSymbolNeeded('$noExitRuntime')
// Same for noExitRuntime. The default for pthreads should always be false
// otherwise pthreads would never complete and attempts to pthread_join to
// them would block forever.
// pthreads can still choose to set `noExitRuntime` explicitly, or
// call emscripten_unwind_to_js_event_loop to extend their lifetime beyond
// their main function. See comment in src/runtime_pthread.js for more.
noExitRuntime = 0;
#endif
#endif

#if MAIN_MODULE
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5015
5012
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10827
10825
Loading