Skip to content

Commit 37b298a

Browse files
committed
Remove duplicate threadExit code in worke.js
As
1 parent 45aa70c commit 37b298a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/worker.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,22 @@ this.onmessage = function(e) {
203203
if (ex === 'Canceled!') {
204204
Module['PThread'].threadCancel();
205205
} else if (ex != 'unwind') {
206-
#if MINIMAL_RUNTIME
207-
// ExitStatus not present in MINIMAL_RUNTIME
208-
Atomics.store(Module['HEAPU32'], (threadInfoStruct + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2, -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/);
209-
#else
210-
Atomics.store(Module['HEAPU32'], (threadInfoStruct + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2, (ex instanceof Module['ExitStatus']) ? ex.status : -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/);
211-
#endif
212-
213-
Atomics.store(Module['HEAPU32'], (threadInfoStruct + {{{ C_STRUCTS.pthread.threadStatus }}} ) >> 2, 1); // Mark the thread as no longer running.
214206
#if ASSERTIONS
207+
// FIXME(sbc): Figure out if this is still needed or useful. Its not
208+
// clear to me how this check could ever fail. In order to get into
209+
// this try/catch block at all we have already called bunch of
210+
// functions on `Module`.. why is this one special?
215211
if (typeof(Module['_emscripten_futex_wake']) !== "function") {
216212
err("Thread Initialisation failed.");
217213
throw ex;
218214
}
219215
#endif
220-
Module['_emscripten_futex_wake'](threadInfoStruct + {{{ C_STRUCTS.pthread.threadStatus }}}, 0x7FFFFFFF/*INT_MAX*/); // Wake all threads waiting on this thread to finish.
221216
#if MINIMAL_RUNTIME
217+
// ExitStatus not present in MINIMAL_RUNTIME
218+
Module['PThread'].threadExit(-2);
222219
throw ex; // ExitStatus not present in MINIMAL_RUNTIME
223220
#else
221+
Module['PThread'].threadExit((ex instanceof Module['ExitStatus']) ? ex.status : -2);
224222
if (!(ex instanceof Module['ExitStatus'])) throw ex;
225223
#endif
226224
#if ASSERTIONS

0 commit comments

Comments
 (0)