mirror of
				https://github.com/ohwgiles/laminar.git
				synced 2025-06-13 12:54:29 +00:00 
			
		
		
		
	readability: move runFinished into its own function
This commit is contained in:
		
							parent
							
								
									50dd7b47af
								
							
						
					
					
						commit
						dbc75000a5
					
				| @ -496,12 +496,36 @@ void Laminar::assignNewJobs() { | ||||
|                 } | ||||
| 
 | ||||
|                 // setup run completion handler
 | ||||
|                 run->notifyCompletion = [=,&node](const Run* r) { | ||||
|                     node.busyExecutors--; | ||||
|                 run->notifyCompletion = [this](const Run* r) { runFinished(r); }; | ||||
| 
 | ||||
|                 // trigger the first step of the run
 | ||||
|                 if(stepRun(run)) { | ||||
|                     // should never happen
 | ||||
|                     KJ_LOG(INFO, "No steps for run"); | ||||
|                     run->complete(); | ||||
|                 } | ||||
| 
 | ||||
|                 assigned = true; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         if(assigned) { | ||||
|             activeJobs.insert(*it); | ||||
|             it = queuedJobs.erase(it); | ||||
|         } else | ||||
|             ++it; | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Laminar::runFinished(const Run * r) { | ||||
|     Node* node = r->node; | ||||
| 
 | ||||
|     node->busyExecutors--; | ||||
|     KJ_LOG(INFO, "Run completed", r->name, to_string(r->result)); | ||||
|     time_t completedAt = time(0); | ||||
|     db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?)") | ||||
|                      .bind(r->name, r->build, node.name, r->queuedAt, r->startedAt, completedAt, int(r->result), | ||||
|      .bind(r->name, r->build, node->name, r->queuedAt, r->startedAt, completedAt, int(r->result), | ||||
|            r->log, r->parentName, r->parentBuild, r->reason()) | ||||
|      .exec(); | ||||
| 
 | ||||
| @ -527,28 +551,8 @@ void Laminar::assignNewJobs() { | ||||
|     waiters.erase(r); | ||||
| 
 | ||||
|     // remove the workdir
 | ||||
|                     fs::remove_all(wd); | ||||
|     fs::remove_all(r->wd); | ||||
| 
 | ||||
|     // will delete the job
 | ||||
|     activeJobs.get<2>().erase(r); | ||||
|                 }; | ||||
| 
 | ||||
|                 // trigger the first step of the run
 | ||||
|                 if(stepRun(run)) { | ||||
|                     // should never happen
 | ||||
|                     KJ_LOG(INFO, "No steps for run"); | ||||
|                     run->complete(); | ||||
|                 } | ||||
| 
 | ||||
|                 assigned = true; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         if(assigned) { | ||||
|             activeJobs.insert(*it); | ||||
|             it = queuedJobs.erase(it); | ||||
|         } else | ||||
|             ++it; | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -59,6 +59,7 @@ private: | ||||
|     void reapAdvance(); | ||||
|     void assignNewJobs(); | ||||
|     bool stepRun(std::shared_ptr<Run> run); | ||||
|     void runFinished(const Run*); | ||||
| 
 | ||||
|     std::list<std::shared_ptr<Run>> queuedJobs; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user