本文整理汇总了C++中EventHandler::dec方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::dec方法的具体用法?C++ EventHandler::dec怎么用?C++ EventHandler::dec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler::dec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stop
SelectManager::~SelectManager()
{
EventHandler *handler;
EventMap::const_iterator iter;
stop();
FD_ZERO(&m_readSet);
FD_ZERO(&m_writeSet);
for (iter = m_eventMap.begin(); iter != m_eventMap.end(); )
{
handler = iter->second;
if (handler->dec() == 0) delete handler;
iter = m_eventMap.erase(iter);
}
}
示例2: handleFdSet
void SelectManager::handleFdSet()
{
int fd;
int hasEvent;
EventHandler *handler;
EventMap::const_iterator iter;
for (iter = m_eventMap.begin(); iter != m_eventMap.end(); )
{
hasEvent = 0;
fd = iter->first;
handler = iter->second;
if (handler->getRegisterEvent() == NONE)
{
LockGuard<SpinLock> guard(m_lock);
if (handler->dec() == 0) delete handler;
iter = m_eventMap.erase(iter);
continue;
}
if (!handler->hasRead() && FD_ISSET(fd, &m_readSet))
{
hasEvent = 1;
handler->activateRead();
}
if (!handler->hasWrite() && FD_ISSET(fd, &m_writeSet))
{
hasEvent = 1;
handler->activateWrite();
}
if (hasEvent) handleEvent(handler);
++iter;
}
}
示例3: loop
void EpollManager::loop()
{
if (-1 == m_fd)
{
ERRORLOG("epoll not init, exit");
return;
}
int i;
int events;
int eventNum;
EventHandler *handler;
for (; !m_isStop;)
{
eventNum = epoll_wait(m_fd, m_epollEvents, EG_EPOLL_MAX_EVENT, -1);
if (-1 == eventNum)
{
if (EINTR == errno)
{
if (m_isStop)
{
INFOLOG("recv exit signal, exit loop");
}else
{
INFOLOG("EINTR");
}
continue;
}
ERRORLOG1("epoll_wait err, %s", strerror(errno));
break;
}
if (0 == eventNum)
{
ERRORLOG("epoll_wait return 0, exit");
break;
}
for (i = 0; i < eventNum; ++i)
{
handler = (EventHandler *)m_epollEvents[i].data.ptr;
if (NULL == handler)
{
INFOLOG("recv exit notify, exit loop");
break;
}
if (handler->inc() == 1)
{
delete handler;
continue;
}
events = m_epollEvents[i].events;
if ((events & (EPOLLERR | EPOLLHUP))
&& (events & (EPOLLIN | EPOLLOUT)) ==0)
{
events |= EPOLLIN;
}
if (events & EPOLLIN)
{
handler->activateRead();
}
if (events & EPOLLOUT)
{
handler->activateWrite();
}
handleEvent(handler);
if (handler->dec() == 0) delete handler;
}
}
m_isStop = 2;
}