开发者

pthread threadpool?

does the pthread lib include a threadpool implementation? or are there comm开发者_如何学Goonly used libs that folks use/


Jeanna Matthews from Clarkson University has a very nice implementation. Why don't you take a look? It follows the standard thread pool pattern.


Thread pools require some form of inter-thread communication to dispatch tasks which is beyond the remit of basic threading functionality.

Consider something like ØMQ which provides messaging functionality with ITC, IPC, TCP, and PGM sockets all using the same single BSD socket compatible API. One of the ØMQ socket types implements thread pool type functionality but can be extended over multiple hosts and hence is provides significantly greater scalability and flexibility.


There is no official pthread threadpool library, though there are plenty of other people's libraries to be found via Google.


In POSIX stander thraed are created with pthread_create function:

int pthread_create(pthread_t *thread_id, const pthread_attr_t * attr, void *(*start_routine)(void*), void *arg);

for implementing thread pool, i will suggest you to create a bunch of threads with pthread_create function, and once the threads are created then use counting semaphore. To manage the thread allocation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜