summaryrefslogtreecommitdiff
path: root/yhttpd/src/thrd/pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'yhttpd/src/thrd/pool.h')
-rw-r--r--yhttpd/src/thrd/pool.h55
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