00001 /******************************************************************************/ 00002 /* XrdFfsQueue.hh functions to run independent tasks in queue */ 00003 /* */ 00004 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */ 00005 /* All Rights Reserved */ 00006 /* Author: Wei Yang (SLAC National Accelerator Laboratory, 2009) */ 00007 /* Contract DE-AC02-76-SFO0515 with the Department of Energy */ 00008 /******************************************************************************/ 00009 00010 #ifdef __cplusplus 00011 extern "C" { 00012 #endif 00013 00014 #include <stdlib.h> 00015 #include <pthread.h> 00016 00017 struct XrdFfsQueueTasks { 00018 pthread_mutex_t mutex; 00019 pthread_cond_t cond; 00020 short done; 00021 void* (*func)(void*); 00022 void **args; 00023 00024 unsigned int id; 00025 struct XrdFfsQueueTasks *next; 00026 struct XrdFfsQueueTasks *prev; 00027 }; 00028 00029 struct XrdFfsQueueTasks* XrdFfsQueue_create_task(void* (*func)(void*), void **args, short initstat); 00030 void XrdFfsQueue_free_task(struct XrdFfsQueueTasks *task); 00031 void XrdFfsQueue_wait_task(struct XrdFfsQueueTasks *task); 00032 unsigned int XrdFfsQueue_count_tasks(); 00033 00034 int XrdFfsQueue_create_workers(int n); 00035 int XrdFfsQueue_remove_workers(int n); 00036 int XrdFfsQueue_count_workers(); 00037 00038 #ifdef __cplusplus 00039 } 00040 #endif 00041