// Loop through our running children and return a result on the first completed child one found, if one exists
Loop through our running children and return a result on the first completed child one found, if one exists
Loop through our running children and return a result on the first completed child one found if one exists
fn check_children(job_vec: &mut Vec<(std::process::Child, Box<dyn commands::Operation + Send>)>) -> Option<project::Chunk> {
    // we ain't doin shit if there's a 0 size vec
    if job_vec.is_empty() {
        return None;
    }
    // TODO find a nice iterator method to go through this vec... I had trouble with the dyn trait with other methods
    for i in 0..job_vec.len() {
        //println!("checker: Inspecting job: {}", i);
        // Check to see if our child is completed
        match job_vec[i].0.try_wait() {
            Ok(Some(status)) => {
                //println!("checker: Child {} complete", job_vec[i].0.id());
                // Get our job's output
                let job_chunk = job_vec[i].1.getresults();
                // Run our job's cleanup routine
                job_vec[i].1.cleanup();
                //Communicate back to the main project a job success/failure
                //println!("checker: Successfully got a status from a child!");
                //println!("checker: chunk: {}", job_chunk.scene_number);
                //println!("checker: code: {}", status.code().unwrap() as usize);
                // remove the job from our list
                job_vec.remove(i);
                return Some(job_chunk); // git outta here, we can't delete any more if we just removed one
            }
            //Ok(None) => println!("checker: Child is still running"),
            Ok(None) => (),
            Err(e) => panic!("checker: Error attempting to wait: {}", e),
        }
    }
    // If we get here, we're still running every single job and there's nothing to return
    return None;
}
fn check_children ( job_vec : & mut Vec < ( std :: process :: Child , Box < dyn commands :: Operation + Send > ) > ) -> Option < project :: Chunk > { // we ain't doin shit if there's a 0 size vec if job_vec . is_empty ( ) { return None ; } // TODO find a nice iterator method to go through this vec... I had trouble with the dyn trait with other methods for i in 0 .. job_vec . len ( ) { //println!("checker: Inspecting job: {}", i); // Check to see if our child is completed match job_vec [ i ] . 0 . try_wait ( ) { Ok ( Some ( status ) ) => { //println!("checker: Child {} complete", job_vec[i].0.id()); // Get our job's output let job_chunk = job_vec [ i ] . 1 . getresults ( ) ; // Run our job's cleanup routine job_vec [ i ] . 1 . cleanup ( ) ; //Communicate back to the main project a job success/failure //println!("checker: Successfully got a status from a child!"); //println!("checker: chunk: {}", job_chunk.scene_number); //println!("checker: code: {}", status.code().unwrap() as usize); // remove the job from our list job_vec . remove ( i ) ; return Some ( job_chunk ) ; // git outta here, we can't delete any more if we just removed one } //Ok(None) => println!("checker: Child is still running"), Ok ( None ) => ( ) , Err ( e ) => panic ! ( " " e ) , } } // If we get here, we're still running every single job and there's nothing to return return None ; }
Loop through our running children and return a result on the first completed child one found, if one exists
Loop through our running children and return a result on the first completed child one found if one exists
job_vec
&mut Vec<(std::process::Child, Box<dyn commands::Operation + Send>)>