コード例 #1
0
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);
  }
}
コード例 #2
0
ファイル: world.cpp プロジェクト: zukonake/last-day
void World::simulate( void ) noexcept
{
	EntityContainer::simulate();
	ChunkContainer::unloadInactiveChunks();
	nextTick();
	return;
}
コード例 #3
0
ファイル: network.cpp プロジェクト: ffloyd/ds_simul
void Network::run()
{
	while(idle_ticks < max_idle_ticks)
	{
		nextTick();
	}
	printf("NETWORK: All things done.\n");
}
コード例 #4
0
ファイル: gamefield.cpp プロジェクト: IlyaGusev/BreakOut
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()));
}