Ejemplo n.º 1
0
KKJobList::KKJobList (const KKJobList&  jobs):
     KKQueue<KKJob>      (jobs.Owner ()),
     jobIdLookUpTable    (),
     jobIdLookUpTableIdx (),
     log                 (jobs.log),
     manager             (jobs.manager)
{
  KKJobList::const_iterator  idx;
  for  (idx = jobs.begin ();  idx != jobs.end ();  idx++)
  {
    KKJobPtr j = *idx;
    if  (Owner ())
      PushOnBack (j->Duplicate ());
    else
      PushOnBack (j);
  }
}
Ejemplo n.º 2
0
void   KKJobManager::Run ()
{
  log.Level (10) << "KKJobManager::Run." << endl;

  bool  keepOnRunning = true;

  KKJobListPtr  executedJobs  = NULL;
  KKJobListPtr  jobsToExecute = GetNextSetOfJobs (NULL);

  while  (keepOnRunning  &&  (!quitRunning))
  {
    if  (jobsToExecute)
    {
      delete  executedJobs;  executedJobs = NULL;

      executedJobs = new KKJobList (this);
      executedJobs->Owner (true);

      KKJobList::iterator  idx;
      for  (idx = jobsToExecute->begin ();  idx != jobsToExecute->end ();  idx++)
      {
        KKJobPtr  j = *idx;
        j->ProcessNode ();
        executedJobs->PushOnBack (j->Duplicate ());
      }
      delete  jobsToExecute;  jobsToExecute = NULL;
    }
    else
    {
      if  (!(jobs->JobsStillRunning ()))
      {
        keepOnRunning = false;
      }
      else
      {
        // We will sleep for a bit until there are more jobs to run
        log.Level (10) << "KKJobManager::Run     No jobs avaialble to run; will sleep a bit." << endl;
        osSleep ((float)(30 + rand () % 10)); 
      }
    }

    if  (keepOnRunning)
      jobsToExecute = GetNextSetOfJobs (executedJobs);

    delete  executedJobs;  executedJobs = NULL;
  }


  Block ();
  StatusFileRefresh ();
  if  ((!quitRunning)  &&  (status != KKJob::jsDone))
  {
    if  (status != KKJob::jsDone)
    {
      GenerateFinalResultsReport ();
      
      status = KKJob::jsDone;
    
      ofstream*  statusFile = StatusFileOpen (ios::app);

      *statusFile << "Status" << "\t" << StatusStr () << endl;

      ReportCpuTimeUsed (statusFile);

      statusFile->close ();
      delete  statusFile;
    }
  }
  EndBlock ();


  log.Level (10) << "KKJobManager::Run    Exiting." << endl;
}  /* Run */