shettyh / threadpool

Golang simple thread pool implementation
Apache License 2.0
102 stars 21 forks source link

Why bother with a chan chan of workers? #6

Open SSSCeph opened 2 years ago

SSSCeph commented 2 years ago

https://github.com/shettyh/threadpool/blob/b99fd8aaa9451aabc3d737e614c9a24a44d2a84c/threadpool.go#L15

Wouldn't it be simpler to just have workers pull jobs off the job queue instead of a double redirect / dispatch? (get job, find worker, queue job).

masterdrone1999 commented 2 years ago

https://github.com/shettyh/threadpool/blob/b99fd8aaa9451aabc3d737e614c9a24a44d2a84c/threadpool.go#L15

Wouldn't it be simpler to just have workers pull jobs off the job queue instead of a double redirect / dispatch? (get job, find worker, queue job).

i think workerPool is like the manager between jobQueue and worker, because of workerPool.size = threadPool.size