Muduo网络库大并发服务器类图
2021-08-31 17:35:09 12 举报
自己收集整理,欢迎查看
作者其他创作
大纲/内容
BlockingQueue无界缓冲区类
+deque<T> _queue+MutexLock _mutex+Condition _cond
+《create》BlockingQueue()+put()+take()
Condition条件变量类
+ &_mutex+_condid
+ wait() +notify+notifyAll
Threadpool线程池类
+BlockingQueue<Task> _tasks;+vector<Thread*> _threads;
+《create》Threadpool()+start(int numThreads); +addTask(Task& task); +run0();- runInThread()
Channel类
+《create》Threadpool()+handleEvent() 调用handleread或者write+enableReading()+enableWirteing()- update()
《《interface》》IRun0
+run0
EvenLoop时间循环类
+Epoll* _pPoller;+int _eventfd; +const pid_t _threadId;+MutexLock _mutex+ vector<Task> _pendingFunctors;+TimerQueue* _pTimerQueue;
+loop()开始循环+update(Channel* pChannel)+queueInLoop(Task& task)处理其他线程+runInLoop(Task& task)本线程-doPendingFunctors()交换出任务做
TimerQueue定时器队列类
+int _timerfd;+TimerList _pTimers;+EventLoop* _pLoop;+Channel* _pTimerfdChannel;
《《interface》》IChannelCallback
+handleRead() +handleWrite()
《《interface》》IMuduoUser
span style=\"font-weight: normal;\
《《interface》》IRun2
+run2
Timestamp时间戳类
+_microSecondsSinceEpoch
+valid() bool +microSecondsSinceEpoch()+toString() string+now()+nowAfter(double seconds)+nowMicroSeconds()
Timer定时器类
+Timestamp _stamp+Timestamp _id+double _interval 重复次数
+isRepeat()bool是否重复+getId()+getstamp()+moveToNext()移到下一时刻
Task任务类
+IRun0* _func0;+IRun2* _func2;+std::string _str;+void* _param;
doTask
Thread线程类
+ _task
+《create》Thread(Task& task)+start()+gettid() pid_t
Epoll类
+int _epollfd;+struct epoll_event _events[MAX_EVENTS];
+《create》Epoll()+《destory》~Epoll()+void poll(vector<Channel*>* pChannels)输出结构体+void update(Channel* pChannel)上树
TcpConnect连接通信类
+int _sockfd;+Channel* _pSocketChannel;+EventLoop* _pLoop; -Buffer _inBuf;-Buffer _outBuf;
+ send()+handleRead()+handleWrite()
Tcpserver服务器类
+《create》TcpServer(EventLoop* pLoop)+《destory》 ~TcpServer()+start()接受一个连接+setCallback(IMuduoUser* pUser)+newConnection(int sockfd)接收一个新通话
Echoserver终端服务器类
+EventLoop* _pLoop;+TcpServer _pServer;+ThreadPool _threadpool;+int _timer;+int _index;
+《create》EchoServer(EventLoop* pLoop);span style=\"font-size: inherit;\
MutexLockGuard锁变量类
+ &_mutex
+《create》MutexLockGuard() +《destory》~MutexLockGuard()
《《interface》》IAcceptorCallback
+newConnection(sockfd)
Acceptor接受连接类
+int _listenfd;+Channel* _pSocketAChannel;+EventLoop* _pLoop;
+start()接收链接调用+setCallback(IAcceptorCallback* pCallback)+handleRead()+handleWrite()-createAndListen()
MutexLock互斥锁类
+_mutexid
+ lock()+unlock()
fds
0 条评论
下一页