コード例 #1
0
ファイル: queueman.cpp プロジェクト: jjardon/eos
void QueueManager::sortQueue(QueueType queue) {
	lockQueue(queue);

	_queue[queue].sort(queueComp);

	unlockQueue(queue);
}
コード例 #2
0
bool
RunPotentialParamsQueue::getWork()
{
  if(!fs::exists(mySettings.queueFile))
    return false;

  ip::file_lock lock(mySettings.queueFile.string().c_str());
  ip::scoped_lock< ip::file_lock> lockQueue(lock);

  fs::fstream queueStream(mySettings.queueFile);
  std::stringstream takenWorkItems, originalContents;
  std::string line;
  size_t numParamsRead = 0;
  while(numParamsRead < myNumWorkItemsChunk)
  {
    if(!std::getline(queueStream, line))
      break;

    bool takenWork = false;
    if(!line.empty() && line[0] != '#')
    {
      const boost::optional< Params> & params = readParams(line);
      if(params)
      {
        ++numParamsRead;
        myParamsQueue.push(*params);
        takenWorkItems << "#" << spl::os::getProcessId() << " " << line << "\n";
        takenWork = true;
      }
    }
    if(!takenWork)
      originalContents << line << "\n";
  }

  if(numParamsRead > 0)
  {
    // Save the rest of the file to buffer
    std::copy(std::istreambuf_iterator< char>(queueStream),
        std::istreambuf_iterator< char>(),
        std::ostreambuf_iterator< char>(originalContents));

    // Go back to the start of the file
    queueStream.clear(); // Clear the EoF flag
    queueStream.seekg(0, std::ios::beg);

    // Write out the whole new contents
    // First the rest of the file
    std::copy(std::istreambuf_iterator< char>(originalContents),
        std::istreambuf_iterator< char>(),
        std::ostreambuf_iterator< char>(queueStream));
    // Then the part of the queue that we're running
    std::copy(std::istreambuf_iterator< char>(takenWorkItems),
        std::istreambuf_iterator< char>(),
        std::ostreambuf_iterator< char>(queueStream));
  }
  queueStream.close();

  return numParamsRead > 0;
}
コード例 #3
0
void CommandQueue::waitCycle()
{
    if (lockQueue())
    {
        executeCommands();
        unlockQueue();
    }
}
コード例 #4
0
ファイル: renderable.cpp プロジェクト: Supermanu/xoreos
void Renderable::show() {
	lockQueue(_queueVisible);

	addToQueue(_queueVisible);
	sortQueue(_queueVisible);

	unlockQueue(_queueVisible);
}
コード例 #5
0
 void submitJob( IJob* job )
 {
     m_jobQueue.push_back( job );
     lockQueue();
     m_tailIndex++;
     m_queueIsEmpty = false;
     unlockQueue();
 }
コード例 #6
0
ファイル: queueman.cpp プロジェクト: jjardon/eos
void QueueManager::removeFromQueue(QueueType queue,
		const std::list<Queueable *>::iterator &ref) {

	lockQueue(queue);

	_queue[queue].erase(ref);

	unlockQueue(queue);
}
コード例 #7
0
 void clearQueue()
 {
     lockQueue();
     m_headIndex = 0;
     m_tailIndex = 0;
     m_queueIsEmpty = true;
     unlockQueue();
     m_jobQueue.resizeNoInitialize( 0 );
 }
コード例 #8
0
ファイル: queueman.cpp プロジェクト: jjardon/eos
std::list<Queueable *>::iterator QueueManager::addToQueue(QueueType queue, Queueable &q) {
	lockQueue(queue);

	_queue[queue].push_back(&q);
	std::list<Queueable *>::iterator ref = --_queue[queue].end();

	unlockQueue(queue);

	return ref;
}
コード例 #9
0
ファイル: queueman.cpp プロジェクト: jjardon/eos
void QueueManager::clearQueue(QueueType queue) {
	lockQueue(queue);

	for (std::list<Queueable *>::iterator q = _queue[queue].begin();
	     q != _queue[queue].end(); ++q)
		(*q)->kickedOut(queue);

	_queue[queue].clear();

	unlockQueue(queue);
}
コード例 #10
0
ファイル: uqmlog.c プロジェクト: ex/urquan-masters
// sets the maximum log lines captured for the final
// display to the user on failure exit
void
log_captureLines (int num)
{
	if (num > MAX_LOG_ENTRIES)
		num = MAX_LOG_ENTRIES;
	if (num < 1)
		num = 1;
	maxDisp = num;

	// remove any extra lines already on queue
	lockQueue ();
	removeExcess (0);
	unlockQueue ();
}
コード例 #11
0
ファイル: uqmlog.c プロジェクト: ex/urquan-masters
static int
acquireSlot (void)
{
	int slot;

	lockQueue ();
	
	removeExcess (1);
	slot = qhead;
	qhead = (qhead + 1) % MAX_LOG_ENTRIES;
	++qtotal;
	
	unlockQueue ();

	return slot;
}
コード例 #12
0
ファイル: GameEngine.cpp プロジェクト: T4g1/Embryon
/**
 * Traitement du module
 */
void GameEngine::frame()
{
    log("Debut de la gestion du jeu");
    loadGameConfig();

    while(core->getIsRunning()) {
        // Attend que la file de message ne soit plus vide
        boost::mutex::scoped_lock lockQueue(mutexQueue);
        while(message_queue.empty())
            condQueue.wait(lockQueue);
        lockQueue.unlock();

        // Traitement des messages
        processQueue();
    }

    log("Fin de la gestion du jeu");
}
コード例 #13
0
ファイル: EventsEngine.cpp プロジェクト: T4g1/Embryon
/**
 * Traitement du module d'evenements
 */
void EventsEngine::frame()
{
    log("Debut de la gestion des evenements");

    while(core->getIsRunning()) {
        // Attend que la file d'event ou de message ne soit plus vide
        boost::mutex::scoped_lock lockQueue(mutexQueue);
        while(event_queue.empty() && message_queue.empty())
            condQueue.wait(lockQueue);
        lockQueue.unlock();

        // Traitement des messages
        processQueue();

        // Traitement des events
        processEventQueue();
    }
}
コード例 #14
0
void
RunPotentialParamsQueue::updateDoneParams()
{
  if(!fs::exists(mySettings.doneFile))
    return;

  // Update the file of finish parameters
  ip::file_lock lock(mySettings.doneFile.string().c_str());
  ip::scoped_lock< ip::file_lock> lockQueue(lock);

  fs::ofstream doneStream(mySettings.doneFile, std::ios::out | std::ios::app);
  std::for_each(myDoneParams.begin(), myDoneParams.end(),
      boost::bind(&RunPotentialParamsQueue::writeParams, this, _1,
          boost::ref(doneStream)));

  doneStream.close();
  myDoneParams.clear();
}
コード例 #15
0
 IJob* consumeJob()
 {
     if ( m_queueIsEmpty )
     {
         // lock free path. even if this is taken erroneously it isn't harmful
         return NULL;
     }
     IJob* job = NULL;
     lockQueue();
     if ( !m_queueIsEmpty )
     {
         job = m_jobQueue[ m_headIndex++ ];
         if ( m_headIndex == m_tailIndex )
         {
             m_queueIsEmpty = true;
         }
     }
     unlockQueue();
     return job;
 }