void CPCTimerHandler::run(){ //Calculate time handler thread period based on TICKS_PER_SECOND parameter configured in CMake struct timespec stPeriod; stPeriod.tv_sec = 0; stPeriod.tv_nsec = (1000000000 / getTicksPerSecond()); if(stPeriod.tv_nsec < 1){ //Time base under 1 ns is not supported DEVLOG_ERROR("TICKS_PER_SECOND greater than 1000000000 are not supported"); stPeriod.tv_nsec = 1; } //Make this thread periodic unsigned long nOverRuns; struct timespec stAuxTime; clock_gettime(CLOCK_REALTIME, &stAuxTime); stAuxTime.tv_nsec += 100000; pthread_t oThreadId = pthread_self(); if(oThreadId != 0){ if(pthread_make_periodic_np(oThreadId,&stAuxTime,&stPeriod)!= 0){ DEVLOG_ERROR("Error could not set time handler thread period! %s\n", strerror(errno)); return; } } while(isAlive()){ //TODO: Handle overruns nextTick(); pthread_wait_np(&nOverRuns); } }
void World::simulate( void ) noexcept { EntityContainer::simulate(); ChunkContainer::unloadInactiveChunks(); nextTick(); return; }
void Network::run() { while(idle_ticks < max_idle_ticks) { nextTick(); } printf("NETWORK: All things done.\n"); }
GameField::GameField(QGraphicsScene* sc, QObject *parent) : QObject(parent), PLATFORM_SPEED(1.5), BALL_SPEED(2.0), platform(nullptr), balls(), blocks(), anitimer(this), scene(sc), borders() { connect(&anitimer, SIGNAL(timeout()), this, SLOT(nextTick())); }