-
Notifications
You must be signed in to change notification settings - Fork 391
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
Worker Pool for similar tasks #657
Comments
Just in case somebody else is interested - i ended up using the following concept: WP - Worker-Pool (n comlink worker instances)
This is a somewhat cumbersome way but aslong as the worker ist getting released back to the pool at the end - its working. If there is a need for heavy parallel processing and you have a bunch of tasks you can easily use a n-sized worker pool and make sure every available thread is doing as much work as possible (instead of using a distribution algo like round robin) |
I have developed a worker pool (WP) functionality. This WP is relatively simple because my requirements do not involve coordinating multiple WPs. The main functional design of this WP is as follows:
The WP has the following shortcomings:
I have not yet thought too deeply about other issues. I hope this is useful to you. codes in main.js
'const abc = async function(param1,param2,...){ ..... return ......}' |
I would like to use a worker pool to delegate tasks to multiple workers with the same interface.
Without Comlink: When there is a new task to be done, the pool selects a worker that is currently idle and assigns the task to it. For the time a worker is processing a task i mark the worker as "busy" - if the work is done i mark the worker as idle. Its working fine but i need to write my own message protocol ending up writing long switch-case statements
With Comlink: The idea is to request a "free" worker from the worker pool (using a Promise), execute an async function, and process the result in the form of a return value. I can mark the requested worker as "busy" but i have problems mark is as "idle" after returning the value.
Unfortunately, I have not found a way to determine whether or how many "messages" are currently being processed by a worker. So, whether a function is currently being executed via Comlink.
Do you have any idea on how I could solve the problem?
The text was updated successfully, but these errors were encountered: