-
Notifications
You must be signed in to change notification settings - Fork 3
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
unlock worker #4
Conversation
The code is a bit complex to show how we could support parallel work for things other than |
console.log('[Main]:', 'Resolve bar'); | ||
const barVal = importMetaResolve('bar'); | ||
console.log('[Main]:', 'Bar is', barVal); | ||
|
||
// Keep the thread alive a bit to get the last logs. | ||
setTimeout(() => {}, 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way to check that there are logs in progress that haven’t yet been printed? Like that process.stdout
has messages queued or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that I know of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a stream, so is it possible to check whether a stream is empty? Stream::cork() / Stream::uncork() or Stream::on('finished')
@@ -1,28 +1,50 @@ | |||
import { deserialize, serialize } from 'node:v8'; | |||
import { Worker } from 'node:worker_threads'; | |||
import { Worker, MessageChannel, receiveMessageOnPort } from 'node:worker_threads'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the use of MessageChannel
required in order to unlock the main thread? I’m thinking that if we could split this into two PRs, where one does the refactor from SharedArrayBuffer
to MessageChannel
and the other unlocks the main thread, we could use the former to benchmark SharedArrayBuffer
vs MessageChannel
to know which one is faster; and hopefully either approach can accommodate an unlocked main thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they are coupled: postMessage()
is instead of (almost all of the) Atomics
No description provided.