Does anyone know of good patterns/libraries for pooling Web Workers?
I want to be able to do something like the following:
- Set a maximum number of threads.
- The first time I ask for a Worker it creates a new one.
- The next time it will return the previous Worker, unless it is still completing operations, in which case it will create a new one and return that.
- Once we hit the maximum it starts queuing requests for workers up and starting them when a Worker becomes available.
- This currently assumes the pool would all use the same .js file.
Or is there a better approach to this?