@@ -404,6 +404,7 @@ var LibraryPThread = {
404
404
405
405
// Creates a new web Worker and places it in the unused worker pool to wait for its use.
406
406
allocateUnusedWorker : function ( ) {
407
+ var worker ;
407
408
#if MINIMAL_RUNTIME
408
409
var pthreadMainJs = Module [ 'worker' ] ;
409
410
#else
@@ -424,12 +425,11 @@ var LibraryPThread = {
424
425
}
425
426
}
426
427
) ;
427
- PThread . unusedWorkers . push ( new Worker ( p . createScriptURL ( 'ignored' ) ) ) ;
428
+ worker = new Worker ( p . createScriptURL ( 'ignored' ) ) ;
428
429
} else
429
430
#endif
430
- PThread . unusedWorkers . push ( new Worker ( new URL ( '{{{ PTHREAD_WORKER_FILE }}}' , import . meta. url ) ) ) ;
431
- return ;
432
- }
431
+ worker = new Worker ( new URL ( '{{{ PTHREAD_WORKER_FILE }}}' , import . meta. url ) ) ;
432
+ } else {
433
433
#endif
434
434
// Allow HTML module to configure the location where the 'worker.js' file will be loaded from,
435
435
// via Module.locateFile() function. If not specified, then the default URL 'worker.js' relative
@@ -443,10 +443,14 @@ var LibraryPThread = {
443
443
// Use Trusted Types compatible wrappers.
444
444
if ( typeof trustedTypes != 'undefined' && trustedTypes . createPolicy ) {
445
445
var p = trustedTypes . createPolicy ( 'emscripten#workerPolicy2' , { createScriptURL : function ( ignored ) { return pthreadMainJs } } ) ;
446
- PThread . unusedWorkers . push ( new Worker ( p . createScriptURL ( 'ignored' ) ) ) ;
446
+ worker = new Worker ( p . createScriptURL ( 'ignored' ) ) ;
447
447
} else
448
448
#endif
449
- PThread . unusedWorkers . push ( new Worker ( pthreadMainJs ) ) ;
449
+ worker = new Worker ( pthreadMainJs ) ;
450
+ #if EXPORT_ES6 && USE_ES6_IMPORT_META
451
+ }
452
+ #endif
453
+ PThread . unusedWorkers . push ( worker ) ;
450
454
} ,
451
455
452
456
getNewWorker : function ( ) {
0 commit comments