@@ -5,11 +5,11 @@ import WasmEnableThreads from "consts:wasmEnableThreads";
5
5
import BuildConfiguration from "consts:configuration" ;
6
6
7
7
import { dumpThreads , onWorkerLoadInitiated , resolveThreadPromises } from "../browser" ;
8
- import { mono_wasm_pthread_on_pthread_created } from "../worker" ;
8
+ import { mono_wasm_pthread_on_pthread_created , onRunMessage } from "../worker" ;
9
9
import { PThreadLibrary , PThreadWorker , getModulePThread , getUnusedWorkerPool } from "./emscripten-internals" ;
10
- import { loaderHelpers , mono_assert } from "../../globals" ;
10
+ import { Module , loaderHelpers , mono_assert } from "../../globals" ;
11
11
import { mono_log_warn } from "../../logging" ;
12
- import { PThreadPtrNull } from "./types" ;
12
+ import { PThreadPtr , PThreadPtrNull } from "./types" ;
13
13
14
14
/** @module emscripten-replacements Replacements for individual functions in the emscripten PThreads library.
15
15
* These have a hard dependency on the version of Emscripten that we are using and may need to be kept in sync with
@@ -22,6 +22,13 @@ export function replaceEmscriptenPThreadLibrary(modulePThread: PThreadLibrary):
22
22
const originalLoadWasmModuleToWorker = modulePThread . loadWasmModuleToWorker ;
23
23
const originalThreadInitTLS = modulePThread . threadInitTLS ;
24
24
const originalReturnWorkerToPool = modulePThread . returnWorkerToPool ;
25
+ const original_emscripten_thread_init = ( Module as any ) [ "__emscripten_thread_init" ] ;
26
+
27
+
28
+ ( Module as any ) [ "__emscripten_thread_init" ] = ( pthread_ptr : PThreadPtr , isMainBrowserThread : number , isMainRuntimeThread : number , canBlock : number ) => {
29
+ onRunMessage ( pthread_ptr ) ;
30
+ original_emscripten_thread_init ( pthread_ptr , isMainBrowserThread , isMainRuntimeThread , canBlock ) ;
31
+ } ;
25
32
26
33
modulePThread . loadWasmModuleToWorker = ( worker : PThreadWorker ) : Promise < PThreadWorker > => {
27
34
const afterLoaded = originalLoadWasmModuleToWorker ( worker ) ;
0 commit comments