首先是添加注释的源码: // Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: Shuo Chen (chenshuo
原创 2021-03-17 15:58:00
92阅读
首先
原创 2022-09-21 15:42:53
81阅读
总结说的有的过大,算是对自己学习的一个总结。兴许会不断补充。   模型总结 muduo是基于非堵塞的IO和事件驱动的网络库。 muduo的总体结构时one loop per thread+threadpool,图例如以下: mainReactor和subReactor都是EventLoop,在mainReactor中接收连接。把建立后的连接分发到subReactor中。 作者開始在muduo
转载 2017-06-27 10:15:00
252阅读
2评论
muduo的线程模型为one loop per thread+thread pool模型,在前面一篇文章的末尾曾简单的提起过:https://blog.csdn.net/qq_41453285/article/details/105104845 本节以一个Sudoku Solver(数独求解)例子为例,回顾了并发网络服务程序的多种设计方案,并介绍了使用muduo网络库编写多线程服务器的两种最常用手法 在后面“muduo编程示例”相关文章会展现muduo在编写单线程并发网络服务程序方面的能力与便捷性。本文
原创 2021-08-28 15:55:15
515阅读
muduo的线程模型为one loop per thread+thread pool模型,在前面一篇文章的末尾曾简单的提起过:https://blog..net/qq_41453285/article/details/105104845
原创 2022-01-15 16:50:17
433阅读
channel是muduo中的事件分发器,它只属于一个EventLoop,Channel类中保存着IO事件的类型以及对应的回调函数,每个channel只负责一个文件描述符,但它并不拥有这个文件描述符。channel是在epoll和TcpConnection之间起沟通作用,故也叫做通道,其它类通过调用channel的setCallbcak来和建立channel沟通关系。Chan...
原创 2021-06-01 13:13:38
358阅读
看一下muduo实现的epoll// 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...
原创 2021-06-01 13:13:39
203阅读
EventLoop.cc就相当于一个reactor,多线程之间的函数调用(用eventfd唤醒),epoll处理,超时队列处理,对channel的处理。运行loop的进程被称为IO线程,EventLoop提供了一些API确保相应函数在IO线程中调用,确保没有用互斥量保护的变量只能在IO线程中使用,也封装了超时队列的基本操作。EventLoop.h// Copyright...
原创 2021-06-01 13:13:42
314阅读
Atomic是muduo原子操作的实现类。Atomic.h// 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...
原创 2021-06-01 13:13:58
231阅读
GzipFile封装了gzip的一些API,记录一下// 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)#pr...
原创 2021-06-01 13:14:05
213阅读
Connector负责主动发起连接,不负责创建socket,只负责连接的建立,外部调用Connector::start就可以发起连接,Connector具有重连的功能和停止连接的功能,连接成功建立后返回到TcpClient。Connector.h// Copyright 2010, Shuo Chen. All rights reserved.// http://...
原创 2021-06-01 13:14:12
403阅读
Acceptor类用于创建套接字,设置套接字选项,调用listen函数,接受连接,然后调用TcpServer的回调。// Copyright 2010, Shuo Chen. All rights reserved.// http://code.google.com/p/muduo///// Use of this source code is governed b...
原创 2021-06-01 13:13:41
247阅读
LogStream.h// 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)#ifndef MUDUO_BAS...
原创 2021-06-01 13:13:56
360阅读
muduo中的单例模式Singleton.h// 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)#ifn...
原创 2021-06-01 13:13:59
356阅读
muduo中的线程池。ThreadPool.h// 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)#if...
原创 2021-06-01 13:14:01
432阅读
EventLoopThreadPool是IO线程对应的线程池,通过调用start函数来new EventLoopThread创建对应的线程和其loop,并将创建的保存在vector中。创建TcpConnection时,就会从EventLoopThreadPool中获取一个IO线程。EventLoopThreadPool.h// Copyright 2010, Shuo...
原创 2021-06-01 13:14:10
462阅读
muduo用EventLoopThread提供了对应eventloop和thread的封装,意为I/O线程类,EventLoopThread可以创建一个IO线程,通过startLoop返回一个IO线程的loop,threadFunc中开启loop循环,其中的API涉及一些多线程中的互斥量和条件变量的操作。EventLoopThread.h// Copyright 201...
原创 2021-06-01 13:14:11
234阅读
muduo用TcpClient发起连接,TcpClient有一个Connector连接器,TCPClient使用Conneccor发起连接, 连接建立成功后, 用socket创建TcpConnection来管理连接, 每个TcpClient class只管理一个TcpConnecction,连接建立成功后设置相应的回调函数。很显然,TcpClient用来管理客户端连接,真正连接...
原创 2021-06-01 13:14:12
730阅读
AsyncLogging是muduo的日志,程序如果直接让文件写日志可能会发生阻塞,所以有了异步日志这一说。muduo前端设计了2个BufferPtr,分别是currentBuffer_和nextBuffer_,还有一个存放BufferPtr的vector(buffers_)。多个前端线程往currentBuffer_写数据,currentBuffer_写满了将其放入buffe...
原创 2021-06-01 13:19:07
488阅读
TcpServer拥有Acceptor类,新连接到达时new TcpConnection后续客户端和TcpConnection类交互。TcpServer管理连接和启动线程池,用Acceptor接受连接。// Copyright 2010, Shuo Chen. All rights reserved.// http://code.google.com/p/muduo/...
原创 2021-07-30 10:02:14
198阅读
  • 1
  • 2
  • 3
  • 4
  • 5