Exemplo n.º 1
0
gep::Result gep::TaskWorker::runSingleTask()
{
    ITask* pTaskToExecute = nullptr;
    {
        // try to get a task from our internal task list
        ScopedLock<Mutex> lock(m_tasksMutex);
        if(m_tasks.length() == 0)
            return FAILURE;
        pTaskToExecute = m_tasks.lastElement();
        m_tasks.resize(m_tasks.length() - 1);
    }

    pTaskToExecute->execute();
    m_pActiveGroup->taskFinished();
    return SUCCESS;
}
Exemplo n.º 2
0
ProcUnix::ProcUnix(ITask &f)
  : _routine(f), _state(PROC_DEAD)
{
  _pid = fork();
  if (_pid == -1)
    throw std::runtime_error(std::string("fork ") + strerror(errno));
  if (_pid > 0)
    {
      _state = PROC_ALIVE;
    }
  else
    {
      try
        {
          f.execute();
        }
      catch (std::exception& e)
        {
          exit(1);
        }
      exit(0);
    }
}