diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
| commit | b891420946d5269cc326d67555c6aab3db41a01a (patch) | |
| tree | f6c5e7d6dbf18ec8c0ea9ec0b037251df46b4cbb /yhttpd/src/thrd/pool.h | |
| parent | a537e8323d932125232c305f9573daef89aef0df (diff) | |
added yhttpd and ycurses trunk versions
Diffstat (limited to 'yhttpd/src/thrd/pool.h')
| -rw-r--r-- | yhttpd/src/thrd/pool.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/yhttpd/src/thrd/pool.h b/yhttpd/src/thrd/pool.h new file mode 100644 index 0000000..3a5f7b6 --- /dev/null +++ b/yhttpd/src/thrd/pool.h @@ -0,0 +1,55 @@ +#include "../incl.h" + +#ifndef POOL_H +#define POOL_H + +#include <queue> + +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<task*> 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 |
