Пример #1
0
/*..........................................................................*/
int_t QF_run(void) {
    struct sched_param sparam;
    struct timeval timeout = { 0 }; /* timeout for select() */

    QF_onStartup();  /* invoke startup callback */

    /* try to maximize the priority of the ticker thread, see NOTE01 */
    sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
    if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sparam) == 0) {
        /* success, this application has sufficient privileges */
    }
    else {
        /* setting priority failed, probably due to insufficient privieges */
    }

    l_running = (int_t)1;
    while (l_running) {
        QF_onClockTick(); /* clock tick callback (must call QF_TICK_X()) */

        timeout.tv_usec = l_tickUsec; /* set the desired tick interval */
        select(0, 0, 0, 0, &timeout); /* sleep for the desired tick, NOTE05 */
    }
    QF_onCleanup(); /* invoke cleanup callback */
    pthread_mutex_destroy(&QF_pThreadMutex_);

    return (int_t)0; /* return success */
}
Пример #2
0
/*..........................................................................*/
int_t QF_run(void) {
    QF_onStartup();                                     /* startup callback */

            /* raise the priority of this (main) thread to tick more timely */
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
    l_running = (int_t)1;
    while (l_running) {
        Sleep(l_tickMsec);                    /* wait for the tick interval */
        QF_onClockTick();     /* clock tick callback (must call QF_TICKX()) */
    }
    QF_onCleanup();                                     /* cleanup callback */
    QS_EXIT();                               /* cleanup the QSPY connection */
    //DeleteCriticalSection(&l_win32CritSect);
    return (int_t)0;                                      /* return success */
}
Пример #3
0
//............................................................................
int16_t QF::run(void) {
    l_running = true;
    onStartup();                                           // startup callback

               // raise the priority of this (main) thread to tick more timely
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);

    do {
        Sleep(l_tickMsec);                       // wait for the tick interval
        QF_onClockTick();        // clock tick callback (must call QF_TICKX())
    } while (l_running);
    onCleanup();                                           // cleanup callback
    QS_EXIT();                                  // cleanup the QSPY connection
    //DeleteCriticalSection(&l_win32CritSect);
    return static_cast<int16_t>(0);                          // return success
}
Пример #4
0
int_t QF_run(void) {

    QF_onStartup(); /* application-specific startup callback */

    l_isRunning = true; /* QF is running */

    /* set the ticker thread priority below normal to prevent
    * flooding other threads with time events when the machine
    * is very busy.
    */
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);

    while (l_isRunning) {
        Sleep(l_tickMsec); /* wait for the tick interval */
        QF_onClockTick();  /* clock tick callback (must call QF_TICKX()) */
    }
    QF_onCleanup();  /* cleanup callback */
    QS_EXIT();       /* cleanup the QSPY connection */
    //DeleteCriticalSection(&l_win32CritSect);
    //free all "fudged" event pools...
    return (int_t)0; /* return success */
}