Changeset - 8ef16b5f6624
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-09-13 11:20:15

-adjusted parameters of functions so that the pointer to the head function has to be passed to them
-updated faulty notes
-edited main() so that it set the priority of the head distrenjob to zero
-changed queue() to prepare_distrenjob()
-deleted global \"struc distrenjob *head\" variable because it is created in main()
1 file changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -72,13 +72,12 @@ struct general_info {
 
*/
 
void status_report_generator(struct distrenjob **distrenjobs_head);
 
void distrenjob_remove(struct distrenjob **head, struct distrenjob *bj);
 
struct distrenjob *remove_job(int jobnum_t);
 

	
 
struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum);
 
struct distrenjob *head; /*@TODO:declare struct with no starting data */
 

	
 
/* Global Vars, try to cut down on these */
 
jobnum_t jobnum = 0; // The next job number to create in the queue
 
int hcfjob; // Highest consecutively finished job
 
int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs
 

	
 
@@ -160,17 +159,17 @@ void finish_frame(struct distrenjob *dis
 
}
 

	
 

	
 
/**
 
   creates a structure from starting data, then calls another function to actually add that struct to the queue
 
*/
 
void queue(int type, char *name, char *submitter, char *email, int priority, int start_frame, int end_frame)
 
void prepare_distrenjob(struct frameset *head, int type, char *name, char *submitter, char *email, int priority, int start_frame, int end_frame)
 
{
 
  int counter2;
 
  int counter;
 
  
 

	
 
  struct distrenjob *distrenjob;
 

	
 
  distrenjob->type = 1; /*@TODO: add type to blendjob struct*/
 
  distrenjob->name = name;
 
  distrenjob->submitter = submitter;
 
  distrenjob->email = email;
 
@@ -312,43 +311,43 @@ void status_report_generator(struct dist
 

	
 
  general_info.jobs_in_queue = (highest_jobnum - general_info.total_finished_jobs); /*< extraneous parentheses! */
 
}
 

	
 

	
 
/** 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 *job) {
 
void add_job_to_queue(struct distrenjob *head, struct distrenjob *job) {
 
  struct distrenjob *prev_job = head; // create pointer to previous job
 
  struct distrenjob *current_job;     // create pointer to current_job (which job is being compared to)
 

	
 
  // 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 current_job's priority, insert job
 
      prev_job->next = job;                        // keep in mind 1 is the lowest priority
 
      job->next = current_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;
 
  } // end of for statement
 
}
 

	
 
void change_job_priority(int jobnum, int new_priority){
 
void change_job_priority(struct distrenjob *head, int jobnum, int new_priority){
 
  struct distrenjob *job;
 
  job = remove_job(jobnum);
 
  job = remove_job(head, jobnum);
 
  job->priority = new_priority;
 
  add_job_to_queue(job);
 
}
 

	
 
/**
 
   Removes job from queue without freeing/deleting it. Meant to be temporary.
 
 */
 
struct distrenjob *remove_job(int jobnum_t)
 
struct distrenjob *remove_job(struct distrenjob *head, int jobnum_t)
 
{
 
  struct distrenjob *job;
 
  struct distrenjob *prev_job = head;
 

	
 
  for(job = head; job != NULL; job = job->next){
 
    if(job == NULL){
 
@@ -581,12 +580,13 @@ int distrend_config_free(struct distrend
 
int main(int argc, char *argv[])
 
{
 

	
 
  /* @TODO: Put some arg-grabbing code here */
 

	
 
  struct distrenjob *head;
 
  head->priority = 0; // make head have the highest priority
 

	
 
  int cont;
 
  struct distrend_listenset *listenset;
 
  struct distrend_config *config;
 

	
 
  start_data(); // Starts fresh or loads data from xml dump. Should we grab the return?
0 comments (0 inline, 0 general)