Introduction
The project uses Linux epoll and thread poll build the server and have a client demo.
the thread pool has two-part, one is buffer, like a message queue, use a producer-consumer model implement by condition, and the other is multithread by with mutex to avoid deadlock.
epoll provides a simple but high-efficient polling mechanism:
(1) epoll_create1 creates a epoll instance;
(2) epoll_ctl modifies the file descriptors in epoll instance;
(3) epoll_wait is used to wait I/O events.
Requirements
- when you want architecture to support multiple clients at the same time.
How to get it?
git clone https://github.com/henrytien/threadpool_epoll.git
Building and run
If your system doesn’t installed log4cpp, visit Log for C++ Project and you can download and install.
- building the server
cd threadpool_epollandsh start.sh - building the client demo
cd client && make && sh client.sh
Design
Here are class diagram and sequence diagram.
-
class diagram
-
sequence diagram
Examples
-
start three clients
-
clients
-
work
-
log
-
github
threadpool_epoll
Refrence
[1]cpprefrence
[2]StarUML
[3]GDB
[4]epoll
[5]Class diagram