@@ -229,16 +229,16 @@ var LibraryPThread = {
229229 loadWasmModuleToWorker : ( worker ) = > new Promise ( ( onFinishedLoading ) => {
230230 worker . onmessage = ( e ) => {
231231 var d = e [ 'data' ] ;
232- var cmd = d [ ' cmd' ] ;
232+ var cmd = d . cmd ;
233233
234234 // If this message is intended to a recipient that is not the main
235235 // thread, forward it to the target thread.
236- if ( d [ ' targetThread' ] && d [ ' targetThread' ] != _pthread_self ( ) ) {
237- var targetWorker = PThread . pthreads [ d [ ' targetThread' ] ] ;
236+ if ( d . targetThread && d . targetThread != _pthread_self ( ) ) {
237+ var targetWorker = PThread . pthreads [ d . targetThread ] ;
238238 if ( targetWorker ) {
239- targetWorker . postMessage ( d , d [ ' transferList' ] ) ;
239+ targetWorker . postMessage ( d , d . transferList ) ;
240240 } else {
241- err ( `Internal error! Worker sent a message "${ cmd } " to target pthread ${ d [ ' targetThread' ] } , but that thread no longer exists!` ) ;
241+ err ( `Internal error! Worker sent a message "${ cmd } " to target pthread ${ d . targetThread } , but that thread no longer exists!` ) ;
242242 }
243243 return ;
244244 }
@@ -248,10 +248,10 @@ var LibraryPThread = {
248248 } else if ( cmd === 'spawnThread' ) {
249249 spawnThread ( d ) ;
250250 } else if ( cmd === 'cleanupThread' ) {
251- cleanupThread ( d [ ' thread' ] ) ;
251+ cleanupThread ( d . thread ) ;
252252#if MAIN_MODULE
253253 } else if ( cmd === 'markAsFinished' ) {
254- markAsFinished ( d [ ' thread' ] ) ;
254+ markAsFinished ( d . thread ) ;
255255#endif
256256 } else if ( cmd === 'loaded' ) {
257257 worker . loaded = true ;
@@ -266,13 +266,13 @@ var LibraryPThread = {
266266#endif
267267 onFinishedLoading ( worker ) ;
268268 } else if ( cmd === 'alert' ) {
269- alert ( `Thread ${ d [ ' threadId' ] } : ${ d [ ' text' ] } ` ) ;
269+ alert ( `Thread ${ d . threadId } : ${ d . text } ` ) ;
270270 } else if ( d . target === 'setimmediate' ) {
271271 // Worker wants to postMessage() to itself to implement setImmediate()
272272 // emulation.
273273 worker . postMessage ( d ) ;
274274 } else if ( cmd === 'callHandler' ) {
275- Module [ d [ ' handler' ] ] ( ...d [ ' args' ] ) ;
275+ Module [ d . handler ] ( ...d . args ) ;
276276 } else if ( cmd ) {
277277 // The received message looks like something that should be handled by this message
278278 // handler, (since there is a e.data.cmd field present), but is not one of the
@@ -333,28 +333,28 @@ var LibraryPThread = {
333333
334334 // Ask the new worker to load up the Emscripten-compiled page. This is a heavy operation.
335335 worker . postMessage ( {
336- ' cmd' : 'load' ,
337- ' handlers' : handlers ,
336+ cmd : 'load' ,
337+ handlers : handlers ,
338338#if WASM2JS
339339 // the polyfill WebAssembly.Memory instance has function properties,
340340 // which will fail in postMessage, so just send a custom object with the
341341 // property we need, the buffer
342- ' wasmMemory' : { 'buffer' : wasmMemory . buffer } ,
342+ wasmMemory : { 'buffer' : wasmMemory . buffer } ,
343343#else // WASM2JS
344- 'wasmMemory' : wasmMemory ,
344+ wasmMemory,
345345#endif // WASM2JS
346- 'wasmModule' : wasmModule ,
346+ wasmModule,
347347#if LOAD_SOURCE_MAP
348- 'wasmSourceMap' : wasmSourceMap ,
348+ wasmSourceMap,
349349#endif
350350#if USE_OFFSET_CONVERTER
351- 'wasmOffsetConverter' : wasmOffsetConverter ,
351+ wasmOffsetConverter,
352352#endif
353353#if MAIN_MODULE
354- 'dynamicLibraries' : dynamicLibraries ,
354+ dynamicLibraries,
355355 // Share all modules that have been loaded so far. New workers
356356 // won't start running threads until these are all loaded.
357- 'sharedModules' : sharedModules ,
357+ sharedModules,
358358#endif
359359#if ASSERTIONS
360360 'workerID' : worker . workerID ,
@@ -503,7 +503,7 @@ var LibraryPThread = {
503503 // the onmessage handlers if the message was coming from valid worker.
504504 worker . onmessage = ( e ) => {
505505#if ASSERTIONS
506- var cmd = e [ 'data' ] [ ' cmd' ] ;
506+ var cmd = e [ 'data' ] . cmd ;
507507 err ( `received "${ cmd } " command from terminated worker: ${ worker . workerID } ` ) ;
508508#endif
509509 } ;
@@ -519,7 +519,7 @@ var LibraryPThread = {
519519 dbg ( `_emscripten_thread_cleanup: ${ ptrToString ( thread ) } ` )
520520#endif
521521 if ( ! ENVIRONMENT_IS_PTHREAD ) cleanupThread ( thread ) ;
522- else postMessage ( { ' cmd' : 'cleanupThread' , 'thread' : thread } ) ;
522+ else postMessage ( { cmd : 'cleanupThread' , thread } ) ;
523523 } ,
524524
525525 _emscripten_thread_set_strongref : ( thread ) => {
@@ -618,10 +618,10 @@ var LibraryPThread = {
618618
619619 worker . pthread_ptr = threadParams . pthread_ptr ;
620620 var msg = {
621- ' cmd' : 'run' ,
622- ' start_routine' : threadParams . startRoutine ,
623- ' arg' : threadParams . arg ,
624- ' pthread_ptr' : threadParams . pthread_ptr ,
621+ cmd : 'run' ,
622+ start_routine : threadParams . startRoutine ,
623+ arg : threadParams . arg ,
624+ pthread_ptr : threadParams . pthread_ptr ,
625625 } ;
626626#if OFFSCREENCANVAS_SUPPORT
627627 // Note that we do not need to quote these names because they are only used
@@ -1110,7 +1110,7 @@ var LibraryPThread = {
11101110 // running, but remain around waiting to be joined. In this state they
11111111 // cannot run any more proxied work.
11121112 if (!ENVIRONMENT_IS_PTHREAD) markAsFinished(thread);
1113- else postMessage({ ' cmd' : 'markAsFinished', 'thread': thread });
1113+ else postMessage({ cmd: 'markAsFinished', thread });
11141114 },
11151115
11161116 $markAsFinished: (pthread_ptr) => {
@@ -1242,20 +1242,20 @@ var LibraryPThread = {
12421242 // new thread that has not had a chance to initialize itself and execute
12431243 // Atomics.waitAsync to prepare for the notification.
12441244 _emscripten_notify_mailbox_postmessage__deps : [ '$checkMailbox' ] ,
1245- _emscripten_notify_mailbox_postmessage : ( targetThreadId , currThreadId ) = > {
1246- if ( targetThreadId == currThreadId ) {
1245+ _emscripten_notify_mailbox_postmessage : ( targetThread , currThreadId ) = > {
1246+ if ( targetThread == currThreadId ) {
12471247 setTimeout ( checkMailbox ) ;
12481248 } else if ( ENVIRONMENT_IS_PTHREAD ) {
1249- postMessage ( { ' targetThread' : targetThreadId , ' cmd' : 'checkMailbox' } ) ;
1249+ postMessage ( { targetThread, cmd : 'checkMailbox' } ) ;
12501250 } else {
1251- var worker = PThread . pthreads [ targetThreadId ] ;
1251+ var worker = PThread . pthreads [ targetThread ] ;
12521252 if ( ! worker ) {
12531253#if ASSERTIONS
1254- err ( `Cannot send message to thread with ID ${ targetThreadId } , unknown thread ID!` ) ;
1254+ err ( `Cannot send message to thread with ID ${ targetThread } , unknown thread ID!` ) ;
12551255#endif
12561256 return ;
12571257 }
1258- worker . postMessage ( { ' cmd' : 'checkMailbox' } ) ;
1258+ worker . postMessage ( { cmd : 'checkMailbox' } ) ;
12591259 }
12601260 }
12611261} ;
0 commit comments