Skip to content
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

enhance README to include ideal use case(s) #36

Open
gpolyn opened this issue Apr 29, 2018 · 6 comments
Open

enhance README to include ideal use case(s) #36

gpolyn opened this issue Apr 29, 2018 · 6 comments

Comments

@gpolyn
Copy link

gpolyn commented Apr 29, 2018

I came to workerize-loader for ease-of-use, but now I wonder about about pooling-type issues imposed by my present need for overlapping tasks.

So, I hope this is a helpful suggestion: Clarify use case in README, e.g., greenlet < workerize-loader < workerpool.

For example, does the following feature imply a 'natural' way to limit the number of workers?

     If exported module methods are already async, signature is unchanged

@gpolyn gpolyn changed the title enhance README to include ideal use cases enhance README to include ideal use case(s) Apr 29, 2018
@developit
Copy link
Owner

In the case of workerize and greenlet, no pooling is supported. For those use-cases, I'd recommend Clooney since it has built-in strategies for pooling. I'm going to update the readme to point people towards that library for such use-cases.

@gpolyn
Copy link
Author

gpolyn commented May 1, 2018

Thanks @developit .

(FYI - there is a pending issue with clooneyjs dependency, comlink at GoogleChromeLabs/comlink#63.)

@gpolyn
Copy link
Author

gpolyn commented May 2, 2018

FWIW, here's an example of pooling with workerize-loader: https://github.com/gpolyn/react-and-workerize-loader/blob/master/src/workerPool2.js.

@developit
Copy link
Owner

developit commented May 15, 2018

Hi @gpolyn - there's some extra stuff going on in that file that you can get rid of when using Workerize. Here's a modified version:
https://gist.github.com/developit/65a2212731f6b00a8aaa55d70c594f5c

Perk: you can just call your exported functions on the pool, no need for the .queueJob(name) stuff:

import Worker from 'workerize-loader!./worker';
import WorkerPool from './worker-pool';
let pool = new WorkerPool(Worker, 4);
for (let i=10; i--; ) pool.doThing();

@gpolyn
Copy link
Author

gpolyn commented May 19, 2018

@developit thanks a lot!

Your mod revised at line 33: https://gist.github.com/gpolyn/9a2ced1e6f4f12375f7430cfcc2ba6b6

@developit
Copy link
Owner

Good catch, I updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants