-
Notifications
You must be signed in to change notification settings - Fork 603
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
The queue is growing as big as the memory! #20
Comments
I am not sure if this should be solved from the thread pool side. It is possible but it would make everything too complex for no good reason imo:
I think a simpler solution is to simply check how much work there already is in the queue before adding new tasks. Pseudocode:
|
While assisting someone online with the same issue, I noticed that the library should provide a function that return the job queue length |
Just for posterity, here is a reproducing example: int main(int argc, char *argv[]){
threadpool thpool = thpool_init(4);
printf("%d\n", thpool->jobqueue_p.len );
return 0;
} |
I have created a producer and several comsumer threads.
Producer add work to the threads using thread_add_work function.
Consumers threadpool threads do their job.
Problem is:
if number of thread is 5 and producer is 100 times faster than the consumer, then queue size is just increasing.
The text was updated successfully, but these errors were encountered: