コード例 #1
0
NW::ExecutiveReply * NW::Executive::decisions( const Decision::DecisionFactory * factory, const Nepomuk::Resource & res )
{
    if ( ! canProcess( res ) )
        return 0;

    return this->requestDecisions(factory,res);
}
コード例 #2
0
ファイル: run.cpp プロジェクト: cvrobot/cradlehead
void SysTick_Handler(void) {
    // reload the hardware watchdog
    runFeedIWDG();

	//计算空闲时间百分比 通过串口发送给上位机  没什么用途
    idlePercent = 100.0f * (idleCounter-oldIdleCounter) * minCycles / totalCycles;
//  空闲时间百分比 = 100 * (本次循环次数 - 上次循环次数) * 最小周期 / 总共周期
    oldIdleCounter = idleCounter;
    totalCycles = 0;

    simplebgc_process_inqueue();//parse input from uart2 and send to uart3
    simplewofl_process_inqueue();//parse input from uart3 and send to uart2
	canProcess();
	cliCheck();    //ascii

    runMilis++;
}
コード例 #3
0
void TimerInfo::process(quint32 events)
{
    Q_UNUSED(events)

    uint64_t value;
    int res;
    do {
        res = read(fd, &value, sizeof(value));
    } while (-1 == res && EINTR == errno);

    if (Q_UNLIKELY(-1 == res)) {
        qErrnoWarning("%s: read() failed", Q_FUNC_INFO);
    }

    QTimerEvent event(timerId);
    QCoreApplication::sendEvent(object, &event);

    // Check if we are NOT going to be deleted
    if (canProcess()) {
        struct timeval now;
        struct timeval delta;
        struct itimerspec spec;

        spec.it_interval.tv_sec  = 0;
        spec.it_interval.tv_nsec = 0;

        gettimeofday(&now, 0);
        EventDispatcherEPollPrivate::calculateNextTimeout(this, now, delta);
        TIMEVAL_TO_TIMESPEC(&delta, &spec.it_value);
        if (0 == spec.it_value.tv_sec && 0 == spec.it_value.tv_nsec) {
            spec.it_value.tv_nsec = 500;
        }

        if (-1 == timerfd_settime(fd, 0, &spec, 0)) {
            qErrnoWarning("%s: timerfd_settime() failed", Q_FUNC_INFO);
        }
    }
}
コード例 #4
0
bool EventDispatcherEPollPrivate::processEvents(QEventLoop::ProcessEventsFlags flags)
{
    Q_Q(EventDispatcherEPoll);

    const bool exclude_notifiers = (flags & QEventLoop::ExcludeSocketNotifiers);
    const bool exclude_timers    = (flags & QEventLoop::X11ExcludeTimers);

    exclude_notifiers && disableSocketNotifiers(true);
    exclude_timers    && disableTimers(true);

    m_interrupt = false;
    Q_EMIT q->awake();

    bool result = q->hasPendingEvents();

    QCoreApplication::sendPostedEvents();

    bool can_wait =
            !m_interrupt
            && (flags & QEventLoop::WaitForMoreEvents)
            && !result
            ;

    int n_events = 0;

    if (!m_interrupt) {
        int timeout = 0;

        if (!exclude_timers && !m_zero_timers.isEmpty()) {
            QVector<ZeroTimer*> timers;
            auto it = m_zero_timers.constBegin();
            while (it != m_zero_timers.constEnd()) {
                ZeroTimer *data = it.value();
                data->ref();
                timers.push_back(data);
                ++it;
            }

            for (ZeroTimer *data : timers) {
                if (data->canProcess() && data->active) {
                    data->active = false;

                    QTimerEvent event(data->timerId);
                    QCoreApplication::sendEvent(data->object, &event);

                    result = true;
                    if (!data->active) {
                        data->active = true;
                    }
                }

                data->deref();
            }
        }

        if (can_wait && !result) {
            Q_EMIT q->aboutToBlock();
            timeout = -1;
        }

        struct epoll_event events[10024];
        do {
            n_events = epoll_wait(m_epoll_fd, events, 10024, timeout);
        } while (Q_UNLIKELY(-1 == n_events && errno == EINTR));

        for (int i = 0; i < n_events; ++i) {
            struct epoll_event &e = events[i];
            auto data = static_cast<EpollAbastractEvent*>(e.data.ptr);
            data->ref();
        }

        for (int i = 0; i < n_events; ++i) {
            struct epoll_event &e = events[i];
            auto data = static_cast<EpollAbastractEvent*>(e.data.ptr);
            if (data->canProcess()) {
                data->process(e.events);
            }

            data->deref();
        }
    }

    exclude_notifiers && disableSocketNotifiers(false);
    exclude_timers    && disableTimers(false);

    return result || n_events > 0;
}