msgqueue_thrdpool icon indicating copy to clipboard operation
msgqueue_thrdpool copied to clipboard

线程池的销毁问题

Open zxg-code opened this issue 2 years ago • 1 comments

为什么在线程池的终止函数thrdpool_terminate中,没有唤醒所有等待进程的操作呢?这样的话如果整个消息队列是空的,线程会在第56行的message get操作中阻塞住吧?很费解啊

zxg-code avatar Apr 29 '23 02:04 zxg-code

线程池后来改为用msgqueue实现了,msgqueue的set_nonblock函数内部有broadcast,会让等待的线程在没有消息的时候直接返回。代码在: https://github.com/Barenboim/msgqueue_thrdpool/blob/9b9aedf1d526815a19663880fd16460d55bef560/thrdpool.c#L92

Barenboim avatar Apr 29 '23 03:04 Barenboim