threads.js
threads.js copied to clipboard
Support for worker-to-worker communication
Allow exposing a worker's functionality to other workers using MessageChannel.
Workers must handle a new meta message transferring a pair of message ports and listen on it / send to it, too, not just the main thread.
To Do
- Allow communication using arbitrary MessagePort instances
- Allow passing a MessagePort to spawn() (maybe rather create a new function)
- Add Thread.isTerminatable()
- Export MessageChannel & MessagePort
any update on this? would love to leverage MessageChannel for worker to worker support, bypassing the main thread
Haven't found time to work on that yet, but it's good to know that there is interest in that 👍
Seems currently we can manually pass in MessageChannel as options, to setup communication between two workers?
@linonetwo Do you have a code snippet demonstrating communication between two workers?