From 9cd3ccffd5372dfde3af478e3f832f18db4be3f1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:41 +0200 Subject: tagging tags --- yhttpd-0.7.2/src/thrd/pool.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 yhttpd-0.7.2/src/thrd/pool.h (limited to 'yhttpd-0.7.2/src/thrd/pool.h') diff --git a/yhttpd-0.7.2/src/thrd/pool.h b/yhttpd-0.7.2/src/thrd/pool.h new file mode 100755 index 0000000..3a5f7b6 --- /dev/null +++ b/yhttpd-0.7.2/src/thrd/pool.h @@ -0,0 +1,55 @@ +#include "../incl.h" + +#ifndef POOL_H +#define POOL_H + +#include + +using namespace std; + +class pool +{ +private: + friend class thro; + + struct task + { + void(*p_func)(void*); + void *p_void; + + task(void(*p_func)(void*), void *p_void) + { + this->p_func = p_func; + this->p_void = p_void; + } + }; + + pthread_mutex_t mut_threads; + pthread_mutex_t mut_queue_tasks; + pthread_mutex_t mut_num_avail_threads; + pthread_cond_t cond_new_task; + + int i_num_avail_threads; + int i_num_total_threads; + + queue queue_tasks; + + int increase_pool(int i_num); + void add_task( void(*p_func)(void*), void* p_void ); + static void* wait_for_task(void *p_void); + static void run_func(void *p_void); + +public: + pool(); + ~pool(); + + void run(void* p_void); + bool allow_user_login(); + +#ifdef NCURSES + + void print_pool_size(); +#endif +}; + +#endif -- cgit v1.2.3