当前位置: 首页>>代码示例>>C++>>正文


C++ EventHandler::dec方法代码示例

本文整理汇总了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);
    }
}
开发者ID:ivanchen36,项目名称:eagle,代码行数:16,代码来源:SelectManager.cpp

示例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;
    }
}
开发者ID:ivanchen36,项目名称:eagle,代码行数:36,代码来源:SelectManager.cpp

示例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;
}
开发者ID:ivanchen36,项目名称:eagle,代码行数:80,代码来源:EpollManager.cpp


注:本文中的EventHandler::dec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。