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


C++ EventDispatcher::exec方法代码示例

本文整理汇总了C++中EventDispatcher::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ EventDispatcher::exec方法的具体用法?C++ EventDispatcher::exec怎么用?C++ EventDispatcher::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventDispatcher的用法示例。


在下文中一共展示了EventDispatcher::exec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cml

void Application::Private::checkTimers()
{
    List<Timer*> expiredTimerList;
    {
        ContextMutexLocker cml(m_runningTimerListMutex);
        if (m_runningTimerList.empty()) {
            return;
        }
        Timer *const firstExpiredTimer = m_runningTimerList.front();
        {
            // We control here the case in which the timer that was going to expire
            // (the head of the queue) was removed before actually expiring. With this
            // check we won't fire an incorrect timer when it had already time remaining.
            const iint32 msDelta = firstExpiredTimer->d->m_remaining - m_sleepTime;
            if (msDelta) {
                std::vector<Timer*>::iterator it;
                for (it = m_runningTimerList.begin(); it != m_runningTimerList.end(); ++it) {
                    Timer *const currTimer = *it;
                    currTimer->d->m_remaining -= m_sleepTime;
                }
                m_sleepTime = std::min(msDelta, m_defaultSleepTime);
                return;
            }
        }
        m_nextTimeout = firstExpiredTimer->d->m_remaining;
        std::vector<Timer*>::iterator it = m_runningTimerList.begin();
        while (it != m_runningTimerList.end()) {
            Timer *const currTimer = *it;
            if (currTimer->d->m_remaining == firstExpiredTimer->d->m_remaining) {
                if (currTimer->d->m_timeoutType == Timer::SingleShot) {
                    currTimer->d->m_state = Timer::Stopped;
                    it = m_runningTimerList.erase(it);
                } else {
                    currTimer->d->m_remaining = currTimer->d->m_interval;
                    ++it;
                }
                expiredTimerList.push_back(currTimer);
            } else {
                break;
            }
        }
        if (!m_runningTimerList.empty()) {
            while (it != m_runningTimerList.end()) {
                Timer *const currTimer = *it;
                currTimer->d->m_remaining -= m_nextTimeout;
                ++it;
            }
            std::sort(m_runningTimerList.begin(), m_runningTimerList.end(), PrivateImpl::timerSort);
            Timer *const nextTimer = m_runningTimerList.front();
            m_sleepTime = nextTimer->d->m_remaining;
        } else {
            m_sleepTime = -1;
        }
    }
    List<Timer*>::iterator it;
    for (it = expiredTimerList.begin(); it != expiredTimerList.end(); ++it) {
        Timer *const currTimer = *it;
        EventDispatcher *eventDispatcher = new EventDispatcher(q);
        Event *event = new Event(currTimer, Event::Timeout);
        eventDispatcher->postEvent(event);
        eventDispatcher->exec();
    }
}
开发者ID:ereslibre,项目名称:ideallibrary-old,代码行数:63,代码来源:application.cpp


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