summaryrefslogtreecommitdiff
path: root/src/thrd/pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/thrd/pool.h')
-rw-r--r--src/thrd/pool.h66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/thrd/pool.h b/src/thrd/pool.h
index 87b73c2..c6f1b60 100644
--- a/src/thrd/pool.h
+++ b/src/thrd/pool.h
@@ -27,48 +27,60 @@
#ifndef POOL_H
#define POOL_H
-using namespace std;
-
-struct task
-{
- void(*p_func)(void*);
- void *p_void;
+#include <queue>
- task(void(*p_func)(void*), void *p_void)
- {
- this->p_func = p_func;
- this->p_void = p_void;
- }
-};
+using namespace std;
class pool
{
private:
friend class thro;
- 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;
+ struct task
+ {
+ void(*p_func)(void*);
+ void *p_void;
- static int i_num_avail_threads;
- static int i_num_total_threads;
+ task(void(*p_func)(void*), void *p_void)
+ {
+ this->p_func = p_func;
+ this->p_void = p_void;
+ }
+ };
- static int i_max_queue_size;
- static int i_cur_queue_index;
- static int i_free_queue_index;
- static task** queue_tasks;
+ 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 int increase_pool(int i_num);
+ 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:
- static void init();
- static void destroy();
+ pool();
+ ~pool();
+
+ void run(void* p_void);
+ bool allow_user_login();
- static void run(void* p_void);
- static bool allow_user_login();
+ int _send(_socket *p_sock, const char *sz, int len);
+ int _read(_socket *p_sock, char *sz, int len);
+ int _close(_socket *p_sock);
+ void _main_loop_init();
+ bool _main_loop_do_ssl_stuff(int &i_new_sock);
+ _socket* _create_container(int& i_sock);
+ int _make_server_socket(int i_port);
+};
+
+ void print_pool_size();
+#endif
};
#endif