Web Workers API
11–20 of 47 posts
Re: Web Workers API
#12Two lesser known really cool things about Web Workers: 1. They kind of allow for stopping synchronous operations, example: some regexes have "catastrophic backtracking", executing them will take a really long time, so what do you do if you have to execute user-provided regexes, especially if on the server? Detecting potentially catastrophic regexes is tough, reimplementing the regex engine in order to make it yield t…
Atomics.wait() cannot be called on the main thread (i.e. when your global is a Window object).
Re: Web Workers API
#13Two lesser known really cool things about Web Workers: 1. They kind of allow for stopping synchronous operations, example: some regexes have "catastrophic backtracking", executing them will take a really long time, so what do you do if you have to execute user-provided regexes, especially if on the server? Detecting potentially catastrophic regexes is tough, reimplementing the regex engine in order to make it yield t…
> and then use Atomics.wait on the main thread to block The main thread is not allowed to use Atomics.wait. I’m not certain what the implementation status of this is because I’ve never used it and I have a vague feeling I heard that one browser shipped it without that restriction, but at the very least you may get a TypeError in some user agents and you can expect to in all user agents at some point in the future whe…
I'll test out the regex thing in the following days as I need it for that exact use case, I just assumed killing the web worker would... work, hopefully that's the case otherwise I'm back to square 0 :D
---
Edit: MDN says: "The terminate() method of the Worker interface immediately terminates the Worker. This does not offer the worker an opportunity to finish its operations; it is stopped at once." so if that's not the case either the engine is wrong or the docs are wrong.
Re: Web Workers API
#14Two lesser known really cool things about Web Workers: 1. They kind of allow for stopping synchronous operations, example: some regexes have "catastrophic backtracking", executing them will take a really long time, so what do you do if you have to execute user-provided regexes, especially if on the server? Detecting potentially catastrophic regexes is tough, reimplementing the regex engine in order to make it yield t…
Atomics.wait() cannot be called on the main thread (i.e. when your global is a Window object).
Re: Web Workers API
#15Re: Web Workers API
#16Two lesser known really cool things about Web Workers: 1. They kind of allow for stopping synchronous operations, example: some regexes have "catastrophic backtracking", executing them will take a really long time, so what do you do if you have to execute user-provided regexes, especially if on the server? Detecting potentially catastrophic regexes is tough, reimplementing the regex engine in order to make it yield t…
We use this to convert async browser APIs to service synchronous callbacks that our C library compiled to WebAssembly expects.
Re: Web Workers API
#17Re: Web Workers API
#18If you're interested in leveraging web workers easily for repetitive compute-heavy tasks in a webapp, i've built a little library that takes care of launching and managing worker threads for you: https://github.com/GitSquared/rinzler
Re: Web Workers API
#19If you're interested in leveraging web workers easily for repetitive compute-heavy tasks in a webapp, i've built a little library that takes care of launching and managing worker threads for you: https://github.com/GitSquared/rinzler
Nice. Do you also support SharedArrayBuffers or does everything need to be serializable that is sent to/from WebWorkers?
Re: Web Workers API
#20https://hyperscript.org/features/worker/
We tried to improve the API to this very cool feature.