浅析muduo网络库之Poller

作者: 谢昆明 | 来源:发表于2018-01-09 20:43 被阅读36次

poll相关的有三个类

关系如下:

class Poller
class PollPoller : public Poller
class EPollPoller : public Poller

poll的作用

等待事件发生,通知调用者

int numEvents = ::epoll_wait(epollfd_,
                               &*events_.begin(),
                               static_cast<int>(events_.size()),
                               timeoutMs);

接口一:Timestamp EPollPoller::poll(int timeoutMs, ChannelList* activeChannels)

@parm timeoutMs: 这个时间估计是等待多久
@param activeChannels: 记录有多少个事件发生,这边抽象了一个通道Channel

接口二:

poll需要指定监听哪几个通道,因此有增删改查的功能

virtual void removeChannel(Channel* channel) = 0;
virtual void updateChannel(Channel* channel) = 0;

打赏

如果这篇文章解决了您的问题,让我买根烟抽抽。

支付宝.jpg 微信.jpg

相关文章

网友评论

    本文标题:浅析muduo网络库之Poller

    本文链接:https://www.haomeiwen.com/subject/vnignxtx.html