From 0537da9d1e0f593130fc3967befb71e673b016bc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:42 +0200 Subject: tagging ychat-0.5.4 --- src/pool.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 src/pool.h (limited to 'src/pool.h') diff --git a/src/pool.h b/src/pool.h new file mode 100755 index 0000000..27f093f --- /dev/null +++ b/src/pool.h @@ -0,0 +1,52 @@ +#include "incl.h" +#include "thrd.h" +#include "s_tool.h" +#include "s_conf.h" +#include "s_mutx.h" + +#ifndef POOL_H +#define POOL_H + +#include + +using namespace std; + +class pool +{ +private: + 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(); +}; + +#endif -- cgit v1.2.3