# HG changeset patch # User LordOfWar # Date 2009-09-13 12:44:12 # Node ID 633e938f261d476f103de08a80ecb907320e00d1 # Parent b236a45982d4e1ba88f83c5ec9b24ce6d8407a4d -add a function prototype for add_job_to_queue() -adjusted change_job_priority() to add the job before the jobs of its same priority if it has already been started, but add it at after the jobs of its same priority if it hasn't been started diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -74,6 +74,7 @@ void status_report_generator(struct dist void distrenjob_remove(struct distrenjob **head, struct distrenjob *bj); struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum); +void add_job_to_queue(struct distrenjob *head, struct distrenjob *job); /* Global Vars, try to cut down on these */ jobnum_t jobnum = 0; // The next job number to create in the queue @@ -314,7 +315,7 @@ void status_report_generator(struct dist /** - Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. + Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. */ /** Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. */ void add_job_to_queue(struct distrenjob *head, struct distrenjob *job) { @@ -340,10 +341,31 @@ void add_job_to_queue(struct distrenjob /** @arg head I may end up changing the head if job == head */ -void change_job_priority(struct distrenjob **head, struct distrenjob *job, int new_priority){ +void change_job_priority(struct distrenjob *head, struct distrenjob *job, int new_priority){ distrenjob_remove(head, job); job->priority = new_priority; - add_job_to_queue(head, job); + struct distrenjob *current_job; + struct distrenjob *prev_job = head; + + if(job->frameset[0].status == 0){ // if job was not yet started + add_job_to_queue(head, job); + } + else{ // if job has already been started then place it before the jobs with the same priority + // iterate through linked list of jobs + for(current_job = head; current_job != NULL; current_job = current_job->next){ + if(current_job == NULL){ // if it has reached the end of the list, add job there + current_job = job; + break; + } + else if(job->priority <= current_job->priority){ // if job's priority is less than or equal to current_job's priority, insert job + prev_job->next = job; // keep in mind 1 is the highest priority given to jobs, head has a + job->next = current_job; // priority of zero so it will always be before other jobs + break; + } + + prev_job = current_job; + } + } } /**