Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var threadInfoStruct = 0; // Info area for this thread in Emscripten HEAP (shared). If zero, this worker is not currently hosting an executing pthread.
var selfThreadId = 0; // The ID of this thread. 0 if not hosting a pthread.
var parentThreadId = 0; // The ID of the parent pthread that launched this thread.
#if !WASM_BACKEND
#if !WASM_BACKEND && !MODULARIZE
var tempDoublePtr = 0; // A temporary memory area for global float and double marshalling operations.
#endif

Expand Down Expand Up @@ -59,10 +59,6 @@ this.addEventListener('error', function(e) {
console.error(e.error);
});

function threadPrint() {
var text = Array.prototype.slice.call(arguments).join(' ');
console.log(text);
}
function threadPrintErr() {
var text = Array.prototype.slice.call(arguments).join(' ');
console.error(text);
Expand All @@ -72,20 +68,19 @@ function threadAlert() {
var text = Array.prototype.slice.call(arguments).join(' ');
postMessage({cmd: 'alert', text: text, threadId: selfThreadId});
}
out = threadPrint;
err = threadPrintErr;
var err = threadPrintErr;
this.alert = threadAlert;

#if WASM
Module['instantiateWasm'] = function(info, receiveInstance) {
// Instantiate from the module posted from the main thread.
// We can just use sync instantiation in the worker.
instance = new WebAssembly.Instance(wasmModule, info);
var instance = new WebAssembly.Instance(wasmModule, info);
// We don't need the module anymore; new threads will be spawned from the main thread.
wasmModule = null;
receiveInstance(instance); // The second 'module' parameter is intentionally null here, we don't need to keep a ref to the Module object from here.
return instance.exports;
}
};
#endif

var wasmModule;
Expand Down Expand Up @@ -275,4 +270,4 @@ this.onmessage = function(e) {
console.error(e.stack);
throw e;
}
}
};