Muduo source code analysis of SocketOps class

SocketOps Encapsulation of socket settings API Relatively simple, comments have been written // Copyright 2010, Shuo Chen. All rights reserved. // http://code.google.com/p/muduo/ // // Use of this source code is governed by a BSD-style license // that can be found in the License file. // Author: Shuo Chen (chenshuo at chenshuo dot com) // // […]

muduo source code analysis of poller/EpollPoller multiplexing class

Introduction Poller is an abstract virtual base class of the I/O multiplexing interface, which encapsulates the I/O multiplexing API. Muduo provides EPollPoller and PollPoller derived classes (epoll and poll), so select is not supported. newDefaultPoller() selects epoll by default Main interface poll It is the core function of Poller. Use poll or epoll_wait of derived […]

Muduo source code analysis of EventLoop event loop class

Introduction EventLoop.cc is equivalent to a reactor, function calling between multiple threads (waking up with eventfd), epoll processing, timeout queue processing, and channel processing. The process running the loop is called an IO thread. EventLoop provides some APIs to ensure that the corresponding functions are called in the IO thread, to ensure that variables not […]

Muduo source code analysis: AsyncLogging asynchronous log class

Introduction AsyncLogging is muduo’s log. If the program directly writes logs to files, it may be blocked. The muduo front-end has designed two BufferPtrs, namely currentBuffer_ and nextBuffer_, and a vector (buffers_) that stores BufferPtr. Multiple front-end threads write data to currentBuffer_. When currentBuffer_ is full, put it into buffers_ and notify the back-end thread […]

muduo asynchronous log library

Article directory 1. Log database model 2. Front-end 2.1 Logger class 2.2 Impl class 2.3 LogStream class 2.4 Summary 3. Backend refer to 1. Log database model component Muduo log library consists of front-end and back-end. The muduo log library is an asynchronous high-performance log library. Its performance overhead is about 1.0us~1.6us for each log […]

Muduo source code analysis channel channel class

Introduction Channel is the event distributor in muduo. It belongs to only one EventLoop. The Channel class stores the type of IO event and the corresponding callback function. Each channel is only responsible for one file descriptor, but it does not own this file descriptor. The channel plays a communication role between epoll and TcpConnection, […]

1.15.C++ project: Design of HttpRequest and HttpResponse modules that imitate muduo library to implement concurrent server

Article directory 1. HttpRequest module 2. HttpResponse module 3. Realize ideas (1) Function (2) Meaning 4. Code 1. HttpRequest module 2. HttpResponse module 3. Implement ideas (1) Function HttpRequest module Store HTTP request information Receive a piece of data, parse it according to the HTTP request format, and get each key element and put it […]

1.16.C++ project: Design of HttpContext and HttpServer modules that imitate the muduo library to implement concurrent servers

Article directory 1. HttpContext module 2. HttpServer module 3. HttpContext module implementation ideas (1) Function (2) Meaning (3) Interface 4. HttpServer module implementation ideas (1) Function (2) Meaning (3) Analysis 5. Code 1. HttpContext module To realize the gradual establishment of an HTTP server, the elements and functions need to be provided! Elements: 1. Routing […]

1.14.C++ project: Design of Util module that imitates muduo library to implement concurrent server

1. Util module 2. Implement ideas (1) Management Implement some tool interfaces Read file contents Write content to file URL encoding URL decoding Get description information through HTTP status code Get mime by file extension Determine whether a file is a directory Determine whether a file is an ordinary file HTTP resource path validity judgment […]

1.9.C++ project: Design of Connection module imitating muduo library to implement concurrent server

The complete project is at: Article directory 1. Connection module: This is a module for overall management of communication connections. All operations on a connection are performed through this module! 2. Functions provided 3. Realize ideas (1) Function (2) Meaning (3) Functional design 4. Framework 5. Code 1. Connection module: This is a module for […]