@@ -107,14 +107,18 @@ var LibraryPThread = {
107
107
PThread . allocateUnusedWorker ( ) ;
108
108
}
109
109
#endif
110
- #if ! MINIMAL_RUNTIME
110
+ #if ! MINIMAL_RUNTIME && PTHREAD_POOL_SIZE
111
111
// MINIMAL_RUNTIME takes care of calling loadWasmModuleToAllWorkers
112
112
// in postamble_minimal.js
113
- addOnPreRun ( ( ) => {
114
- addRunDependency ( 'loading-workers' )
115
- PThread . loadWasmModuleToAllWorkers ( ( ) => removeRunDependency ( 'loading-workers' ) ) ;
113
+ addOnPreRun ( async ( ) => {
114
+ var pthreadPoolReady = PThread . loadWasmModuleToAllWorkers ( ) ;
115
+ #if ! PTHREAD_POOL_DELAY_LOAD
116
+ addRunDependency ( 'loading-workers' ) ;
117
+ await pthreadPoolReady ;
118
+ removeRunDependency ( 'loading-workers' ) ;
119
+ #endif // PTHREAD_POOL_DELAY_LOAD
116
120
} ) ;
117
- #endif
121
+ #endif // !MINIMAL_RUNTIME && PTHREAD_POOL_SIZE
118
122
#if MAIN_MODULE
119
123
PThread . outstandingPromises = { } ;
120
124
// Finished threads are threads that have finished running but we not yet
@@ -366,18 +370,16 @@ var LibraryPThread = {
366
370
} ) ;
367
371
} ) ,
368
372
369
- loadWasmModuleToAllWorkers ( onMaybeReady ) {
370
- #if ! PTHREAD_POOL_SIZE
371
- onMaybeReady ( ) ;
372
- #else
373
+ #if PTHREAD_POOL_SIZE
374
+ async loadWasmModuleToAllWorkers ( ) {
373
375
// Instantiation is synchronous in pthreads.
374
376
if (
375
377
ENVIRONMENT_IS_PTHREAD
376
378
#if WASM_WORKERS
377
379
|| ENVIRONMENT_IS_WASM_WORKER
378
380
#endif
379
381
) {
380
- return onMaybeReady ( ) ;
382
+ return ;
381
383
}
382
384
383
385
let pthreadPoolReady = Promise . all ( PThread . unusedWorkers . map ( PThread . loadWasmModuleToWorker ) ) ;
@@ -387,12 +389,11 @@ var LibraryPThread = {
387
389
// If the user wants to wait on it elsewhere, they can do so via the
388
390
// Module['pthreadPoolReady'] promise.
389
391
Module [ 'pthreadPoolReady' ] = pthreadPoolReady ;
390
- onMaybeReady ( ) ;
391
- #else
392
- pthreadPoolReady . then ( onMaybeReady ) ;
393
- #endif // PTHREAD_POOL_DELAY_LOAD
394
- #endif // PTHREAD_POOL_SIZE
392
+ return ;
393
+ #endif
394
+ return pthreadPoolReady ;
395
395
} ,
396
+ #endif // PTHREAD_POOL_SIZE
396
397
397
398
// Creates a new web Worker and places it in the unused worker pool to wait for its use.
398
399
allocateUnusedWorker ( ) {
0 commit comments