00001 /* 00002 ** AUTHORS: 00003 ** Rama Alebouyeh (rama[at]cs.ucsb.edu) 00004 ** Matthew S Allen (msa[at]cs.ucsb.edu) 00005 */ 00006 #ifndef _JOB_QUEUE_H_ 00007 #define _JOB_QUEUE_H_ 00008 00009 typedef void (*FuncPtr)(void *,void *); 00010 00011 /* job_queue node structure */ 00012 typedef struct node{ 00013 FuncPtr fp; /* pointer to function */ 00014 void * args; /* functioin arguements */ 00015 struct node * next; 00016 } node; 00017 00018 /* queue_queue structure */ 00019 typedef struct{ 00020 node * head; 00021 int size; 00022 pthread_mutex_t access; 00023 pthread_cond_t empty; 00024 } List; 00025 00026 typedef struct{ 00027 void * state; 00028 void * msg; 00029 } JobArgs; 00030 00031 00037 void * job_exec(void *job_q); 00038 00039 00046 void job_submit(List *job_q,FuncPtr func,void* args,int args_size); 00047 00048 00049 00055 List * job_queue_init(int pool_size); 00056 00057 #endif