-
Notifications
You must be signed in to change notification settings - Fork 120
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
docs: An example that implements broadcast communication #656
Conversation
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.
This is amazing, thanks!
Could you rather add it to the docs/examples
section?
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.
You should also make sure to set the flag that makes sure piscina doesn't use blocking Atomics.wait
Of course, I will also add it to |
Yes, setting the flag |
Is to avoid the thread to be blocked when idle (we use |
Thanks, I have modified it. |
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.
lgtm
|
const Piscina = require('piscina'); | ||
const piscina = new Piscina({ | ||
filename: resolve(__dirname, 'worker.js'), | ||
useAtomics: false |
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.
Let's just add a comment of why useAtomics
is disabled, and it should be ready to go
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.
Of course, it is necessary
Co-authored-by: Carlos Fuentes <me@metcoder.dev> (cherry picked from commit d57084a)
It's a PR to solve the problem "add an example to README as to how to broadcast a message to all worker threads using BroadcastChannel". This code has been tested,