-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Request: SharedWorkers in Deno #7728
Comments
Super useful for actor-based systems & data-sharing in general! A worker pretty much is an actor. Timely ask too. CloudFlare just introduced Durable Objects. There's no durability implied here, but the general architecture, within a process, maps pretty clearly to SharedWorkers, each shared worker being a (process-local) (semi-sort-of-) durable object. |
I just read up on that article, posted literally today, quite the coincidence, but it sure seems nice. I was writing code that involved multiple workers to separate and parallelize code, there was one specific worker that had permission to access resources that were slow to use, thus why I moved it to a worker in the first place, and it requires synchronization. Ex: synchronized read / write access to data on the disk. postMessages can come in at any time and fill up the event loop's queue, but the handler will only operate one at a time, you don't want to have multiple workers writing to a file at once. For what I was doing, SharedArray buffers wouldn't have been useful, nor easy to keep in sync. Overall though, the key idea was safety, as only one part of the code has exclusive access and sets up its own barrier to safely provide access to something, without sacrificing performance, as all of the work is done outside of the current thread. The problem arrives when one wants access to those resources from within multiple workers at once. You can't exactly pass a worker into another worker |
We've been talking about this, even before the CloudFlare announcement or this issue. We are leaning towards using workers and One of the big ones on this journey though is we need to properly address structured cloning (#3557), as this is the foundation for the ability deal with objects across the worker barrier. |
Oh, I don't doubt it, it falls perfectly within Deno's philosophy, and it just seems awesome all around. |
Workers is getting some love in the very near future. In fact I believe @bartlomieju has some plans for it this week. |
@kitsonk I didn't mean workers as in |
It's been some time since structured cloning has been working for message passing, and we have functioning MessageChannels! 🎉 Is there anything else that might be blocking a possible implementation? |
Not really, however implementation wise it's gonna be quite challenging task. |
Is it planned that Deno support SharedWorkers and / or ServerWorkers at some point?
I don't see the use for ServiceWorkers in Deno, but SharedWorkers are useful for multi-threaded code that uses normal workers, as they allow access to the same worker via ports.
The text was updated successfully, but these errors were encountered: