pre-threading improves (Felipe)
[MonkeyD.git] / src / include / mk_thread.h
blob998f4e23b0b35f6fd064b4dadf5c1071df01bb0a
1 /* Monkey HTTP Daemon
2 * ------------------
3 * Copyright (C) 2008 Felipe Astroza
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 /* MonkeyD
21 * ------------------
22 * Copyright (C) 2008 Felipe Astroza
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Library General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 #include "monkey.h"
41 #ifndef MK_THREAD_H
42 #define MK_THREAD_H
44 #include <mk_common.h>
46 typedef struct {
47 unsigned int pl_quantity;
48 unsigned int pl_free;
49 mk_queue *pl_rqq; /* Requests queue */
50 int pl_rqq_lock;
51 int pl_lock;
52 int pl_wakeup; /* Threads wait in pl_wakeup address */
53 } mk_thread_pool;
55 typedef struct
57 void (*func)(void *);
58 void *arg;
59 } mk_thread_data;
61 #define MK_THREAD_UNLOCKED_VAL 0
62 #define MK_THREAD_LOCKED_VAL (MK_THREAD_UNLOCKED_VAL+1)
64 mk_thread_pool *mk_thread_pool_create(unsigned int n);
66 void mk_thread_mutex_lock(int *lock);
67 void mk_thread_mutex_unlock(int *lock);
69 int mk_thread_pool_set(mk_thread_pool *pool, void (func)(void *data), void *data);
71 #endif