Oh wai
[ITFoundation.git] / queue.h
1 /*
2  *
3  * Copyright (C) 2003 and beyond by Alexander Strange
4  * and the Dawn Of Infinity developers.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * This license is contained in the file "COPYING",
17  * which is included with this source code; it is available online at
18  * http://www.gnu.org/licenses/gpl.html
19  *
20  */
21
22 /*
23  * $Id$
24  *
25  */
26 #pragma once only
27 #ifndef _QUEUE_H
28 #define _QUEUE_H
29 #include <pthread.h>
30 #include <sys/types.h>
31
32 typedef struct queue {
33     void **data;
34     size_t begin;
35     size_t end;
36     size_t allocated;
37     size_t filled;
38     pthread_rwlock_t pmutex;
39 } queue;
40
41 typedef void    (*qperformer) (void *context, void *p);
42
43 extern queue *qinit(queue *q,size_t defaultsize);
44 extern void qdel(queue *q);
45 extern void *qpop(queue *q);
46 extern void qpush(queue *q, void *p);
47 extern size_t growarray(void ***datap, size_t oldsize);
48 extern void qperform(queue *q, qperformer p, void *pctx);
49 #endif