Skip to content

Simplify startWorker pthread function. NFC #24562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions src/closure-externs/closure-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ var EMSCRIPTEN$AWAIT;
// Don't minify createRequire
var createRequire;

// Don't minify startWorker which we use to start workers once the runtime is ready.
/**
* @param {Object} Module
*/
var startWorker = function(Module) {};

// Closure externs used by library_sockfs.js

/**
Expand Down
2 changes: 1 addition & 1 deletion src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function initRuntime() {
#endif

#if PTHREADS
if (ENVIRONMENT_IS_PTHREAD) return startWorker(Module);
if (ENVIRONMENT_IS_PTHREAD) return startWorker();
#endif

#if STACK_OVERFLOW_CHECK >= 2
Expand Down
4 changes: 3 additions & 1 deletion src/runtime_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var workerID = 0;
var sharedModules = {};
#endif

var startWorker;

if (ENVIRONMENT_IS_PTHREAD) {
// Thread-local guard variable for one-time init of the JS state
var initializedJS = false;
Expand Down Expand Up @@ -58,7 +60,7 @@ if (ENVIRONMENT_IS_PTHREAD) {
self.onmessage = (e) => messageQueue.push(e);

// And add a callback for when the runtime is initialized.
self.startWorker = (instance) => {
startWorker = () => {
// Notify the main thread that this thread has loaded.
postMessage({ cmd: 'loaded' });
// Process any messages that were queued before the thread was ready.
Expand Down
2 changes: 1 addition & 1 deletion src/shell_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function ready() {
#if PTHREADS
// This Worker is now ready to host pthreads, tell the main thread we can proceed.
if (ENVIRONMENT_IS_PTHREAD) {
startWorker(Module);
startWorker();
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3749
3744
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7632
7615
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3955
3950
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8063
8046