diff options
| author | admin (centauri.fritz.box) <puppet@mx.buetow.org> | 2014-07-01 20:17:01 +0200 |
|---|---|---|
| committer | admin (centauri.fritz.box) <puppet@mx.buetow.org> | 2014-07-01 20:17:01 +0200 |
| commit | 174529af9197d99d2c5e8f75798fb6d6d9247254 (patch) | |
| tree | 7bdb29f9391b5a3d3629bba3ebec1ca7832b3c9c /src/thrd/pool.h | |
| parent | 751eada68e49f9ffae9a0be743d88a3ce956883f (diff) | |
| parent | 6fde6b0fe90abde84011202edd40fe46eb06af44 (diff) | |
Diffstat (limited to 'src/thrd/pool.h')
| -rw-r--r-- | src/thrd/pool.h | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/src/thrd/pool.h b/src/thrd/pool.h index 0fe97f3..87b73c2 100644 --- a/src/thrd/pool.h +++ b/src/thrd/pool.h @@ -1,7 +1,7 @@ /*:* *: File: ./src/thrd/pool.h *: - *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT *: *: Copyright (C) 2003 Paul C. Buetow, Volker Richter *: Copyright (C) 2004 Paul C. Buetow @@ -27,53 +27,48 @@ #ifndef POOL_H #define POOL_H -#include <queue> - using namespace std; -class pool +struct task { -private: - friend class thro; + void(*p_func)(void*); + void *p_void; - struct task + task(void(*p_func)(void*), void *p_void) { - void(*p_func)(void*); - void *p_void; + this->p_func = p_func; + this->p_void = p_void; + } +}; - task(void(*p_func)(void*), void *p_void) - { - this->p_func = p_func; - this->p_void = p_void; - } - }; +class pool +{ +private: + friend class thro; - pthread_mutex_t mut_threads; - pthread_mutex_t mut_queue_tasks; - pthread_mutex_t mut_num_avail_threads; - pthread_cond_t cond_new_task; + static pthread_mutex_t mut_threads; + static pthread_mutex_t mut_queue_tasks; + static pthread_mutex_t mut_num_avail_threads; + static pthread_cond_t cond_new_task; - int i_num_avail_threads; - int i_num_total_threads; + static int i_num_avail_threads; + static int i_num_total_threads; - queue<task*> queue_tasks; + static int i_max_queue_size; + static int i_cur_queue_index; + static int i_free_queue_index; + static task** queue_tasks; - int increase_pool(int i_num); - void add_task( void(*p_func)(void*), void* p_void ); + static int increase_pool(int i_num); static void* wait_for_task(void *p_void); static void run_func(void *p_void); public: - pool(); - ~pool(); + static void init(); + static void destroy(); - void run(void* p_void); - bool allow_user_login(); - -#ifdef NCURSES - - void print_pool_size(); -#endif + static void run(void* p_void); + static bool allow_user_login(); }; #endif |
