1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
5 * Copyright (C) 2001-2010, Eduardo Silva P. <edsiper@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Library General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef MK_SCHEDULER_H
23 #define MK_SCHEDULER_H
25 #define MK_SCHEDULER_CONN_AVAILABLE -1
26 #define MK_SCHEDULER_CONN_PENDING 0
27 #define MK_SCHEDULER_CONN_PROCESS 1
29 struct sched_connection
38 struct sched_list_node
45 struct sched_connection
*queue
;
46 struct client_request
*request_handler
;
47 struct sched_list_node
*next
;
51 struct sched_list_node
*sched_list
;
53 /* Struct under thread context */
60 pthread_key_t epoll_fd
;
62 int mk_sched_register_thread(pthread_t tid
, int epoll_fd
);
63 int mk_sched_launch_thread(int max_events
);
64 void *mk_sched_launch_epoll_loop(void *thread_conf
);
65 struct sched_list_node
*mk_sched_get_handler_owner();
66 struct request_idx
*mk_sched_get_request_index();
67 void mk_sched_set_request_index(struct request_idx
*ri
);
69 int mk_sched_get_thread_poll();
70 void mk_sched_set_thread_poll(int epoll
);
72 struct sched_list_node
*mk_sched_get_thread_conf();
73 void mk_sched_update_thread_status(struct sched_list_node
*sched
,
74 int active
, int closed
);
77 int mk_sched_check_timeouts(struct sched_list_node
*sched
);
78 int mk_sched_add_client(struct sched_list_node
*sched
, int remote_fd
);
79 int mk_sched_remove_client(struct sched_list_node
*sched
, int remote_fd
);
80 struct sched_connection
*mk_sched_get_connection(struct sched_list_node
81 *sched
, int remote_fd
);
82 int mk_sched_update_conn_status(struct sched_list_node
*sched
, int remote_fd
,