bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / apache2 / include / fdqueue.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef FDQUEUE_H
18 #define FDQUEUE_H
19 #include "httpd.h"
20 #include <stdlib.h>
21 #if APR_HAVE_UNISTD_H
22 #include <unistd.h>
23 #endif
24 #include <apr_thread_mutex.h>
25 #include <apr_thread_cond.h>
26 #include <sys/types.h>
27 #if APR_HAVE_SYS_SOCKET_H
28 #include <sys/socket.h>
29 #endif
30 #include <apr_errno.h>
31
32 typedef struct fd_queue_info_t fd_queue_info_t;
33
34 apr_status_t ap_queue_info_create(fd_queue_info_t **queue_info,
35                                   apr_pool_t *pool, int max_idlers);
36 apr_status_t ap_queue_info_set_idle(fd_queue_info_t *queue_info,
37                                     apr_pool_t *pool_to_recycle);
38 apr_status_t ap_queue_info_wait_for_idler(fd_queue_info_t *queue_info,
39                                           apr_pool_t **recycled_pool);
40 apr_status_t ap_queue_info_term(fd_queue_info_t *queue_info);
41
42 struct fd_queue_elem_t {
43     apr_socket_t      *sd;
44     apr_pool_t        *p;
45 };
46 typedef struct fd_queue_elem_t fd_queue_elem_t;
47
48 struct fd_queue_t {
49     fd_queue_elem_t    *data;
50     int                 nelts;
51     int                 bounds;
52     apr_thread_mutex_t *one_big_mutex;
53     apr_thread_cond_t  *not_empty;
54     int                 terminated;
55 };
56 typedef struct fd_queue_t fd_queue_t;
57
58 apr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a);
59 apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p);
60 apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p);
61 apr_status_t ap_queue_interrupt_all(fd_queue_t *queue);
62 apr_status_t ap_queue_term(fd_queue_t *queue);
63
64 #endif /* FDQUEUE_H */