コード例 #1
0
 int App::run()
 {
     try{init(); m_running = GL_TRUE;}
     catch(std::exception &e){LOG_ERROR<<e.what();}
     double timeStamp = 0.0;
     
     // Main loop
     while( m_running )
     {            
         // update application time
         timeStamp = getApplicationTime();
         
         // poll io_service if no seperate worker-threads exist
         if(!m_main_queue.get_num_threads()) m_main_queue.io_service().poll();
         
         // poll input events
         pollEvents();
         
         // time elapsed since last frame
         double time_delta = timeStamp - m_lastTimeStamp;
         
         // call update callback
         update(time_delta);
         
         m_lastTimeStamp = timeStamp;
         
         if(needs_redraw())
         {
             // call draw callback
             draw_internal();
             
             // Swap front and back rendering buffers
             swapBuffers();
         }
         
         // perform fps-timing
         timing(timeStamp);
         
         // Check if ESC key was pressed or window was closed or whatever
         m_running = checkRunning();
         
         // fps managment
         float current_fps = 1.f / time_delta;
         
         if(current_fps > m_max_fps)
         {
             double sleep_secs = std::max(0.0, (1.0 / m_max_fps - time_delta));
             this_thread::sleep_for(duration_t(sleep_secs));
         }
     }
     
     // manage tearDown, save stuff etc.
     tearDown();
     
     return EXIT_SUCCESS;
 }
コード例 #2
0
ファイル: myconfig.c プロジェクト: yjcn/gitxx
void initConfig(char *pName,char *pPasswd)
{
	int exitFlag = 0;	/* 0Nothing 1退出 2重启 */
	strcpy(userName,pName);
	strcpy(password,pPasswd);
#ifndef NO_DYLOAD
	if (load_libpcap() == -1) {
		/*初始化libpcap()失败*/
		exit(EXIT_FAILURE);
	}
#endif
	checkRunning(exitFlag);
	getAdapter();
	if (dhcpScript[0] == '\0')	/* 未填写DHCP脚本? */
		strcpy(dhcpScript, D_DHCPSCRIPT);
	newBuffer();
	if (fillHeader()==-1 || openPcap()==-1) {	/* 获取IP、MAC,打开网卡 */
		exit(EXIT_FAILURE);
	}
}
コード例 #3
0
ファイル: queuemanager.cpp プロジェクト: xtalopt/XtalOpt
void QueueManager::checkLoop()
{
  // Ensure that this is only called from the QM thread:
  Q_ASSERT_X(QThread::currentThread() == m_thread, Q_FUNC_INFO,
             "Attempting to run QueueManager::checkLoop "
             "from a thread other than the QM thread. ");

  // Update runtime options by reading a file if we are not using the GUI
  // This needs to be here first because sometimes, our CLI settings are
  // over-written from somewhere else when starting.
  if (!m_opt->usingGUI())
    m_opt->readRuntimeOptions();

  if (!m_opt->readOnly && !m_opt->isStarting) {
    checkPopulation();
    checkRunning();
  }

  QTimer::singleShot(1000, this, SLOT(checkLoop()));
}
コード例 #4
0
ファイル: servicemanager.cpp プロジェクト: andcricardo/pcbsd
void ServiceManager::ProgramInit(QString chroot, QString IP)
{
    // Set any warden stuff
    wDir = chroot;
    wIP = IP;

    listServices->setColumnHidden(0, true);
    listServices->setColumnHidden(1, true);
    
    pushStart->setEnabled(FALSE);
    pushStop->setEnabled(FALSE);
    pushRestart->setEnabled(FALSE);
    pushEnableStartup->setEnabled(FALSE);
    pushDisableStartup->setEnabled(FALSE);
    
     // Connect the buttons
    connect( pushStart, SIGNAL( clicked() ), this, SLOT( startSlot() ) );
    connect( pushStop, SIGNAL( clicked() ), this, SLOT( stopSlot() ) );
    connect( pushRestart, SIGNAL( clicked() ), this, SLOT( restartSlot() ) );
    connect( pushEnableStartup, SIGNAL( clicked() ), this, SLOT( enableSlot() ) );
    connect( pushDisableStartup, SIGNAL( clicked() ), this, SLOT( disableSlot() ) );
    
    
    // Connect the list box
    connect( listServices, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT( listSelectionChanged() ) );
     
    // Start loading the various service files
    populateList();
    
    // Start checking the status of these services
    currentCheckRunningItem = new QTreeWidgetItemIterator(listServices);
    checkRunning();
    
    // Start checking if services are enabled
    checkEnabled();

    if ( ! wDir.isEmpty() )
      textTopLabel->setText(tr("Managing services for Warden IP:") + " " +  wIP);
}