2
3
4
5
25 epoll_close(m_EPollFd);
30 const int numEvents = epoll_wait(m_EPollFd, m_Events.data(), m_Events.size(), timeoutMs);
31 const int saveErrno = WSAGetLastError();
35 FillActiveChannels(numEvents, activeChannels);
37 if (numEvents == m_Events.size())
39 m_Events.resize(m_Events.size() * 2);
42 else if (numEvents == 0)
44 SPICES_CORE_INFO(
"EPollPoller::Poll timeout")
48 if (saveErrno != ERROR_OPERATION_ABORTED)
51 ss <<
"EPollPoller::Poll Error: " << saveErrno;
53 SPICES_CORE_ERROR(ss.str())
66 SOCKET fd = channel->Fd();
67 m_Channels[fd] = channel;
71 Update(EPOLL_CTL_ADD, channel);
75 SOCKET fd = channel->Fd();
78 Update(EPOLL_CTL_DEL, channel);
83 Update(EPOLL_CTL_MOD, channel);
90 SOCKET fd = channel->Fd();
96 Update(EPOLL_CTL_DEL, channel);
103 for (
int i = 0; i < numEvents; ++i)
105 Channel* channel =
static_cast<Channel*>(m_Events[i].data.ptr);
106 channel->SetRevents(m_Events[i].events);
107 activeChannels->push_back(channel);
113 epoll_event event = {};
115 SOCKET fd = channel->Fd();
117 event.events = channel->Events();
118 event.data.sock = fd;
119 event.data.ptr = channel;
121 if(::epoll_ctl(m_EPollFd, operation, fd, &event))
123 if(operation == EPOLL_CTL_DEL)
125 std::stringstream ss;
126 ss <<
"EPollPoller::Update::EPOLL_CTL_DEL Error: " << WSAGetLastError();
128 SPICES_CORE_ERROR(ss.str())
132 std::stringstream ss;
133 ss <<
"EPollPoller::Update::EPOLL_CTL_ADD/MOD Error: " << WSAGetLastError();
135 SPICES_CORE_CRITICAL(ss.str())
void SetPollState(PollState state)
Set Poll State.
PollState GetPollState() const
Get Poll State.
bool IsNoneEvent() const
Determine whether the event is a None Event.
Wrapper of SOCKET'S Event.
virtual ~EPollPoller() override
Destructor Function.
void Update(int operation, Channel *channel) const
Update epoll with operation.
virtual void Poll(int timeoutMs, ChannelList *activeChannels) override
Poll events on EventList.
virtual void UpdateChannel(Channel *channel) override
Update Channel and Update Poll.
virtual void RemoveChannel(Channel *channel) override
Remove Channel and Update Poll.
void FillActiveChannels(int numEvents, ChannelList *activeChannels) const
Fill REvents to ChannelList.
EPollPoller(EventLoop *loop)
Constructor Function.
Wrapper of Poller and wakeup socket to acceptor(SubLoop).
Poller(EventLoop *loop)
Constructor Function.
Inherit from this and Implement Specific Poller.
static constexpr int InitEventListSize