![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
muduo源码解析
文章平均质量分 61
chenshuo muduo
无敌的神龙战士
我是废物
展开
-
muduo
文章目录channelPollerEPollPollerEventLoop(channel 和 epoll之间的桥梁)channel理解为通道,对文件描述符管理的一个类,封装了sockfd和其感兴趣的event 如EOLLIN、EPOLLOUT事件 还绑定了poller返回的具体事件class EpollPoller : public Pollerchannel update => eventLoop update_channel => Poller => epollPoller原创 2022-05-26 18:47:53 · 514 阅读 · 0 评论 -
muduo-tcpConnection
tcpConnectiontcpserver 通过accepter,有一个新用户连接,accep拿到connfdtcpconnection设置channel相应回调,poller调用回调class TcpConnection : NonCopyable, public enable_shared_from_this<TcpConnection>{private: enum StateE { k_disconnected, k_conn原创 2022-05-19 15:29:30 · 97 阅读 · 0 评论 -
muduo库的使用
文章目录网络服务器编程常用模型Reactor模型muduo库的使用流程网络服务器编程常用模型accept + read/write 不是并发服务器accept + fork - process-pre-connection 适合并发连接数不大,计算任务工作量大于fork的开销accept + thread thread-pre-connection 比方案2的开销小了一点,但是并发造成线程堆积过多muduo的网络设计:reactors in threads - one loop per t原创 2022-05-17 15:32:39 · 526 阅读 · 0 评论 -
muduo-Buffer
tcpConnectionclass TcpConnection : NonCopyable, public enable_shared_from_this<TcpConnection>{private: enum StateE { k_disconnected, k_connecting, //正在连接 k_connected, //已连接 k_disconnecting, };public:原创 2022-05-13 15:07:24 · 106 阅读 · 0 评论 -
muduo-sockfd-acceptor
class TcpServer : NonCopyable{public: enum Option { k_noReuse_port, //不可重用 k_reuse_port, //可重用 };public: TcpServer(EventLoop *loop, const InetAddress &listenaddr, const string &name, Option option = k_noReuse_p原创 2022-05-13 15:04:41 · 126 阅读 · 0 评论 -
muduo-thread-eventLoopThread
sockfdclass Socket : NonCopyable{public: explicit Socket(int sockfd) : sockfd_(sockfd) {} ~Socket(); int get_fd() { return sockfd_; } void bind_address(const InetAddress &loacladdr); void listen(); int accept(InetAddress *原创 2022-05-13 14:56:47 · 99 阅读 · 0 评论 -
muduo-currentThread-eventLoop(较难)
文章目录threadEventLoopThreadEventLoopThreadthread不调用linux的 调用c++的using ThreadFunc = function<void()>;class Thread : NonCopyable{public: explicit Thread(ThreadFunc, const string &name = string()); ~Thread(); void start(); void原创 2022-05-12 19:36:30 · 154 阅读 · 0 评论 -
muduo-poller-epollPoller
EPollPoller : public pollerepoll:epoll_createepoll_ctrl add/mod/delepoll_waitclass EpollPoller : public Poller{public: EpollPoller(EventLoop *loop); ~EpollPoller() override; //重写基类的poll方法 TimeStamp poll(int timeout, ChannelList *activ原创 2022-05-12 16:57:10 · 105 阅读 · 0 评论 -
muduo-noncopyable-logger-timeStamp
noncopyable类noncopyable被继承之后,派生类对象可以正常的构造和析构,但是派生类对象无法进行拷贝构造和拷贝赋值操作#ifndef MUDUO_BASE_NONCOPYABLE_H#define MUDUO_BASE_NONCOPYABLE_Hnamespace muduo{class noncopyable{ public: // 拷贝构造和赋值delete掉了 noncopyable(const noncopyable&) = delete; vo原创 2022-05-09 18:47:07 · 120 阅读 · 0 评论 -
muduo-TcpServer-EventLoop-channel
EventLoop // 事件循环pollerchannelchannel其实就是通道,封装了sockfd和感兴趣的event,如EPOLLIN,EPOLLOUT事件还绑定了poller返回的具体事件原创 2022-05-09 22:47:33 · 101 阅读 · 0 评论