5050 // This is the way that we signal to the Web Worker that it is hosting
5151 // a Wasm Worker.
5252#if ASSERTIONS
53- 'name': 'em-ww-' + _wasmWorkersID ,
53+ 'name': 'em-ww-' + wwID ,
5454#else
5555 'name': 'em-ww',
5656#endif
6262
6363addToLibrary ( {
6464 $_wasmWorkers : { } ,
65- #if PTHREADS
66- // When the build contains both pthreads and Wasm Workers, offset the
67- // Wasm Worker ID space to avoid collisions with pthread TIDs (which start
68- // at 42). We use `1 << 21` since it's ~1/2 way through `pid_t` space,
69- // essentially giving pthreads the first 1/2 of the range and wasm workers the
70- // second half.
71- $_wasmWorkersID : { { { 1 < < 21 } } } ,
72- #else
73- $_wasmWorkersID : 1 ,
74- #endif
7565
7666 // Starting up a Wasm Worker is an asynchronous operation, hence if the parent
7767 // thread performs any postMessage()-based wasm function calls to the
@@ -175,7 +165,7 @@ addToLibrary({
175165 } ,
176166
177167 _emscripten_create_wasm_worker__deps : [
178- '$_wasmWorkers' , '$_wasmWorkersID' ,
168+ '$_wasmWorkers' ,
179169 '$_wasmWorkerAppendToQueue' , '$_wasmWorkerRunPostMessage' ,
180170#if ASSERTIONS
181171 'emscripten_has_threading_support' ,
@@ -191,11 +181,11 @@ if (ENVIRONMENT_IS_WASM_WORKER
191181 _wasmWorkers[0] = globalThis;
192182 addEventListener("message", _wasmWorkerAppendToQueue);
193183}` ,
194- _emscripten_create_wasm_worker : ( stackLowestAddress , stackSize ) = > {
184+ _emscripten_create_wasm_worker : ( wwID , stackLowestAddress , stackSize ) => {
195185#if ASSERTIONS
196186 if ( ! _emscripten_has_threading_support ( ) ) {
197187 err ( 'create_wasm_worker: environment does not support SharedArrayBuffer, wasm workers are not available' ) ;
198- return 0 ;
188+ return false ;
199189 }
200190#endif
201191 let worker ;
@@ -205,15 +195,15 @@ if (ENVIRONMENT_IS_WASM_WORKER
205195 var p = trustedTypes . createPolicy (
206196 'emscripten#workerPolicy1' , { createScriptURL : ( ignored ) => { { { wasmWorkerJs } } } }
207197 ) ;
208- worker = _wasmWorkers [ _wasmWorkersID ] = new Worker ( p . createScriptURL ( 'ignored' ) , { { { wasmWorkerOptions } } } ) ;
198+ worker = _wasmWorkers [ wwID ] = new Worker ( p . createScriptURL ( 'ignored' ) , { { { wasmWorkerOptions } } } ) ;
209199 } else
210200#endif
211- worker = _wasmWorkers [ _wasmWorkersID ] = new Worker ( { { { wasmWorkerJs } } } , { { { wasmWorkerOptions } } } ) ;
201+ worker = _wasmWorkers [ wwID ] = new Worker ( { { { wasmWorkerJs } } } , { { { wasmWorkerOptions } } } ) ;
212202 // Craft the Module object for the Wasm Worker scope:
213203 worker . postMessage ( {
214204 // Signal with a non-zero value that this Worker will be a Wasm Worker,
215205 // and not the main browser thread.
216- wwID : _wasmWorkersID ,
206+ wwID,
217207 wasm : wasmModule ,
218208 wasmMemory,
219209 stackLowestAddress, // sb = stack bottom (lowest stack address, SP points at this when stack is full)
@@ -237,9 +227,9 @@ if (ENVIRONMENT_IS_WASM_WORKER
237227 }
238228#endif
239229#if RUNTIME_DEBUG
240- dbg ( "done _emscripten_create_wasm_worker ", _wasmWorkersID )
230+ dbg ( "done _emscripten_create_wasm_worker ", wwID )
241231#endif
242- return _wasmWorkersID ++ ;
232+ return true ;
243233 } ,
244234
245235 emscripten_terminate_wasm_worker : ( id ) => {
0 commit comments