01 Analysis of the Principle of Thread Pool

01 Analysis of the Principle of Thread Pool

01 Thread pool principle analysis
02 Thread pool structure description information
03 Thread pool function analysis
04 Thread pool complete header file and implementation file (.c)

1 Why do we need a thread pool?
We know that multi-channel IO transfer can support the connection and processing of multiple clients. For example, poll explains that he can monitor the return of multiple client requests at a time and traverse the confd array for processing, that is, the Server is directly processed Processing; look at epoll again, he will establish a connection for you when there is a request, and it is very efficient to set it to non-blocking, and it does not need to process the request immediately. Because it has a callback function to help with processing, but in fact it is still handled by the Server itself. If the client is very active, it will cause many callback functions to be processed, which is also very time-consuming, so epoll supports more connections and less active situations.
So can we handle things after the connection is established not on the main thread Server, so this is why we need to use the thread pool.

2 Graphics help understanding
Insert picture description here
后面的章节将会分析线程池结构体成员信息、线程池各个函数描述与注释。

Guess you like

Origin blog.csdn.net/weixin_44517656/article/details/108687205