summaryrefslogtreecommitdiff
path: root/src/thrd
diff options
context:
space:
mode:
Diffstat (limited to 'src/thrd')
-rw-r--r--src/thrd/pool.h66
-rw-r--r--src/thrd/thro.cpp67
-rw-r--r--src/thrd/thro.h54
3 files changed, 39 insertions, 148 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
diff --git a/src/thrd/thro.cpp b/src/thrd/thro.cpp
deleted file mode 100644
index 1d94540..0000000
--- a/src/thrd/thro.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*:*
- *: File: ./src/thrd/thro.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#ifndef THRO_CPP
-#define THRO_CPP
-
-#include "thro.h"
-
-using namespace std;
-
-thro::thro()
-{}
-
-thro::~thro()
-{}
-
-void
-thro::run()
-{
- void *p_void;
- run( p_void );
-}
-
-void
-thro::run( void *p_void )
-{
- elem.p_thro = this;
- elem.p_void = p_void;
- //wrap::POOL->add_task(start_, &elem);
- pthread_create( &pthread, NULL, start_, &elem );
-}
-
-void*
-thro::start_( void *p_void )
-{
- elements *e = (elements*) p_void;
- e->p_thro->start( e->p_void );
-}
-
-void
-thro::start( void *p_void )
-{
- wrap::system_message( THRDSTR );
-}
-
-#endif
diff --git a/src/thrd/thro.h b/src/thrd/thro.h
deleted file mode 100644
index b7dbe1d..0000000
--- a/src/thrd/thro.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*:*
- *: File: ./src/thrd/thro.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../incl.h"
-
-#ifndef THRO_H
-#define THRO_H
-
-using namespace std;
-
-class thro
-{
-private:
- pthread_t pthread;
-
- struct elements
- {
- thro *p_thro;
- void *p_void;
- }
- elem;
-
- static void *start_( void *p_void );
-
-public:
- thro( );
- ~thro( );
- void run();
- void run( void *p_void );
- virtual void start( void *p_void );
-};
-
-#endif