Mymoduo is a small C++11 Reactor-style TCP networking library inspired by
muduo. It is a learning-oriented implementation of the core pieces behind a
multi-threaded event-driven server: EventLoop, Channel, Poller,
Acceptor, TcpConnection, TcpServer, and a round-robin event loop thread
pool.
This repository is positioned as a systems programming project rather than a production networking framework. The goal is to make the event-driven design, thread ownership model, and connection lifecycle explicit enough to discuss in C++ backend and AI infrastructure interviews.
- Linux
epollbased I/O multiplexing. - One loop per thread Reactor model.
eventfdwakeup path for cross-thread task dispatch.- Non-blocking accept and connection file descriptors.
- Input/output buffering with
readv. - Round-robin assignment from the main accept loop to worker subloops.
- Echo server example.
- CMake, Makefile, CI, and focused unit tests for the portable buffer layer.
The full networking library uses Linux-specific APIs:
epolleventfdaccept4SOCK_NONBLOCKSOCK_CLOEXEC
Build the complete server on Linux. On macOS, the CMake project still builds
and tests the portable Buffer component, but skips the Linux-only Reactor
targets.
git clone https://github.com/FILWYZ/Mymoduo.git
cd Mymoduo
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failureOn Linux, run the echo server:
./build/mymoduo_echo_serverThen connect from another terminal:
nc 127.0.0.1 8080The legacy Makefile path is also kept:
make
./bin/muduo_echo_serverTcpServer
|-- Acceptor: accepts new sockets in the main EventLoop
|-- EventLoopThreadPool: owns worker loops
|-- TcpConnection map: tracks live connections by name
EventLoop
|-- Poller / EPollPoller: waits for active file descriptors
|-- Channel: binds fd events to callbacks
|-- eventfd: wakes the loop when other threads queue work
TcpConnection
|-- Channel: handles read, write, close, and error events
|-- Buffer: stores input and output data
|-- callbacks: exposes connection and message events to user code
- The main loop owns listening socket registration and connection bookkeeping.
- Worker loops own established connection I/O.
- Cross-thread operations are routed through
EventLoop::runInLoopandEventLoop::queueInLoop. TcpConnection::sendcapturesshared_from_this()for cross-thread sends so queued writes do not outlive the connection object.Buffer::readFduses scatter/gather I/O to reduce reallocations for bursts.
- Linux-only network backend; no kqueue or IOCP implementation.
- No timer queue, high-water-mark callback, TLS, or backpressure policy yet.
- Logging is intentionally minimal.
- This is a learning project and has not been production load-tested.
- Add timer support with
timerfd. - Add graceful shutdown tests and integration tests for the echo server.
- Add a small benchmark for concurrent echo throughput.
- Add structured logging and configurable log levels.
- Add documentation that maps this implementation against muduo's original abstractions.