首先
原创 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..net/qq_41453285/article/details/105104845
原创 2022-01-15 16:50:17
433阅读
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阅读
分为几个模块 EventLoop、TcpServer、Acceptor、TcpConnection、Channel等 对于EventLoop来说: 他仅仅关注里面的主驱动力,EventLoop中仅仅关注poll,这类系统调用使得其成为Reactor模式,EventLoop中有属于这个loop的全部C
转载 2016-03-09 16:38:00
39阅读
muduo网络库源码解析(1):多线程异步日志库(上)muduo网络库源码解析(2):多线程异步日志库(中)muduo网络库源码解析(3):多线程异步日志库(下)muduo网络库源码解析(4):TimerQueue定时机制muduo网络库源码解析(5):EventLoop,Channel与事件分发机制muduo网络库源码解析(6):TcpServer与TcpConnection(上)muduo网络
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阅读
Logger用来记录和分析日志。Logging.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:57
359阅读
muduo也对线程进行了封装,下面看一下实现。Thread.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 c...
原创 2021-06-01 13:14:02
413阅读
ThreadLocal用来存储线程私有数据的类。// 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:14:03
263阅读
muduo之LogFile,LogFile是控制日志怎么和文件打交道,其中包含常用的对日志处理的一些操作。AsyncLogging异步日志需要调用LogFile的接口将日志写入文件,其中包含了AppendFile类,相当于再AppendFile上面封装了一层。LogFile.h// Use of this source code is governed by a BSD-...
原创 2021-06-01 13:14:06
232阅读
FileUtil用来操作文件。AppendFile用来写日志,使用的fopen函数;ReadSmallFile使用open函数用来读取linux内核的一些信息。FileUtil.h// Use of this source code is governed by a BSD-style license// that can be found in the License...
原创 2021-06-01 13:14:07
462阅读
BlockingQueue是muduo是无界队列,利用队列(deque)实现,向队列中加入和取出元素用互斥量和条件变量结合的方式来操作,就是一个线程同步的问题。BlockingQueue.h// Use of this source code is governed by a BSD-style license// that can be found in the L...
原创 2021-06-01 13:14:08
278阅读
muduo的TimerQueue是基于timerfd_create实现,这样超时很容易和epoll结合起来。等待超时事件保存在set集合中,注意set集合的有序性,从小到大排列,整个对TimerQueue的处理也就是对set集合的操作。实现TimerQueue用了3个set,分别是等待超时事件set,活跃事件set,被撤销定时set。主要是STL的一些操作。TimerQueu...
原创 2021-06-01 13:14:14
188阅读
  • 1
  • 2
  • 3
  • 4
  • 5