diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:42 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:42 +0200 |
| commit | 0537da9d1e0f593130fc3967befb71e673b016bc (patch) | |
| tree | e6733c8494e0dc8df5bd7e5d2dcbd401771272b6 /src/pool.h | |
| parent | 3e382f0c9435cbf72570a87640652ad1551c7cfd (diff) | |
tagging ychat-0.5.4ychat-0.5.4
Diffstat (limited to 'src/pool.h')
| -rwxr-xr-x | src/pool.h | 52 |
1 files changed, 52 insertions, 0 deletions
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 <queue> + +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<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(); +}; + +#endif |
