00001 00005 #ifndef RAZORBACK_THREAD_POOL_H 00006 #define RAZORBACK_THREAD_POOL_H 00007 00008 #include <razorback/visibility.h> 00009 #include <razorback/types.h> 00010 #include <razorback/api.h> 00011 #include <razorback/list.h> 00012 00013 #ifdef __cplusplus 00014 extern "C" { 00015 #endif 00016 struct ThreadPool; 00020 struct ThreadPoolItem 00021 { 00022 struct Thread *thread; 00023 int id; 00024 struct ThreadPool *pool; 00025 }; 00026 00030 struct ThreadPool 00031 { 00032 size_t limit; 00033 int nextId; 00034 struct RazorbackContext *context; 00035 void (*mainFunction) (struct Thread *); 00036 const char *namePattern; 00037 struct List *list; 00038 }; 00039 00048 SO_PUBLIC extern struct ThreadPool * 00049 ThreadPool_Create(int initialThreads, int maxThreads, struct RazorbackContext *context, const char* namePattern, void (*mainFunction) (struct Thread *)); 00050 00055 SO_PUBLIC extern bool 00056 ThreadPool_LaunchWorker(struct ThreadPool *pool); 00057 00063 SO_PUBLIC extern bool 00064 ThreadPool_LaunchWorkers(struct ThreadPool *pool, int count); 00065 00071 SO_PUBLIC extern bool 00072 ThreadPool_KillWorker(struct ThreadPool *pool, int id); 00073 00078 SO_PUBLIC extern bool 00079 ThreadPool_KillWorkers(struct ThreadPool *pool); 00080 00081 #ifdef __cplusplus 00082 } 00083 #endif 00084 #endif // RAZORBACK_THREAD_POOL_H 00085