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

线程池疑惑? #14

Open
L-admin opened this issue Sep 13, 2017 · 0 comments
Open

线程池疑惑? #14

L-admin opened this issue Sep 13, 2017 · 0 comments

Comments

@L-admin
Copy link

L-admin commented Sep 13, 2017

1 if ((pool = (zv_threadpool_t *)malloc(sizeof(zv_threadpool_t))) == NULL){ goto err; }
动态申请pool的内存为什么没有释放?
2 if (pool->shutdown == immediate_shutdown) { break; } else if ((pool->shutdown == graceful_shutdown) && pool->queue_size == 0) { break; }
这里的意思是区别对待2种销毁线程池的方式.选择graceful_shutdown的方式是: 等执行完任务队列所有任务时所有线程再一起退出吗.?
我的意思是假设现在有最后一个任务,线程池里有3个线程,那么有1个线程在执行任务,另外2个在阻塞.
好,现在选择graceful_shutdown销毁线程池,有任务的线程会继续执行, 阻塞的被broad唤醒然后会再再次
cond_wait. 然后再被唤醒(因为前面是do_while),
以上,不知道我的理解对不对?
3 if (task == NULL) { pthread_mutex_unlock(&(pool->lock)); continue; }
在static void *threadpool_worker(void *arg)中加这几行代码是为什么呢?

希望博主赐教. thx.

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

No branches or pull requests

1 participant