Changeset - 9a584f11d162
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-07-15 13:16:53
ohnobinki@ohnopublishing.net
added and integrated blendjob_remove()
1 file changed with 41 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -37,9 +37,11 @@
 
#include <time.h>
 

	
 

	
 
/* internally defined funcs */
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void status_report_generator();
 

	
 
void blendjob_remove(struct blendjob **head, struct blendjob *bj);
 

	
 
// Global Vars, try to cut down on these
 
int jobnum = 0; // The next job number to create in the queue
 
@@ -152,14 +154,16 @@ jobnum++; // Advance the jobnumber for t
 

	
 
/*
 
  Status Report Generator: figures out how much of the job is done, where jobnum corresponds to the job number
 

	
 
  blendjobs_head is a pointer to a pointer because the head of the blendjobs linked list may need to be changed by blendjob_remove
 
*/
 
void status_report_generator(struct blendjob *blendjobs_head)
 
void status_report_generator(struct blendjob **blendjobs_head)
 
{
 
  struct blendjob *blendjob_ptr;
 
  unsigned short workers_working; /*< used to count the total number of workers working */
 
  unsigned int numjobs; /*< used to track number of jobs */
 

	
 
  blendjob_ptr = blendjobs_head;
 
  blendjob_ptr = *blendjobs_head;
 
  workers_working = 0;
 
  numjobs = 0;
 
  
 
@@ -214,6 +218,7 @@ void status_report_generator(struct blen
 
	    /* If all frames are complete */
 
	    {
 
	      blendjob_ptr->priority = 0; /*< set priority to zero to indicate job is complete */
 
	      blendjob_remove(blendjobs_head, blendjob_ptr); /*< remove this job from the linkedlist */
 
	      general_info.total_finished_jobs++; /*< add one to the total finished jobs */
 
	      
 
	    }
 
@@ -333,6 +338,38 @@ void blend_frame_watchdog(struct blendjo
 

	
 
}
 

	
 
/**
 
   Removes a blendjob from the blendjob linkelist.
 

	
 
   @arg head a double pointer. the head pointer will have to be changed if blendjob == *head. Thus, make sure that the pointer points to the pointer to the head that all functions use. (I'm going to come back to this and misunderstand myself ;-))
 
 */
 
void blendjob_remove(struct blendjob **head, struct blendjob *bj)
 
{
 
  struct blendjob *previous_blendjob;
 
  
 
  if(bj == *head)
 
    *head = bj->next;
 
  else
 
    {
 
      
 
      for(previous_blendjob = *head;
 
	  previous_blendjob
 
	    && previous_blendjob->next != bj; /*< stop on the blendjob that comes before bj */
 
	  previous_blendjob = previous_blendjob->next)
 
	/* all of the action is in the definition of the for loop itself */;
 
  
 
      /*
 
	This removes references to bj from the linked list. I.E., we now skip bj when iterating through the list
 
       */
 
      previous_blendjob->next = bj->next;
 
    }
 
  
 
  /* 
 
     @lordofwar: the magic deallocation of memory ;-)
 
   */
 
  free(bj);
 
}
 

	
 

	
 
/* ************************** Main ************************* */
 

	
0 comments (0 inline, 0 general)