xref: /haiku/headers/private/kernel/util/queue.h (revision 893988af824e65e49e55f517b157db8386e8002b)
1 /*
2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 #ifndef _KERNEL_QUEUE_H
6 #define _KERNEL_QUEUE_H
7 
8 #include <kernel.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 typedef struct queue {
15 	void *head;
16 	void *tail;
17 	int count;
18 } queue;
19 
20 int queue_init(queue *q);
21 int queue_remove_item(queue *q, void *e);
22 int queue_enqueue(queue *q, void *e);
23 void *queue_dequeue(queue *q);
24 void *queue_peek(queue *q);
25 
26 typedef struct fixed_queue {
27 	void **table;
28 	int head;
29 	int tail;
30 	int count;
31 	int size;
32 } fixed_queue;
33 
34 int fixed_queue_init(fixed_queue *q, int size);
35 void fixed_queue_destroy(fixed_queue *q);
36 int fixed_queue_enqueue(fixed_queue *q, void *e);
37 void *fixed_queue_dequeue(fixed_queue *q);
38 void *fixed_queue_peek(fixed_queue *q);
39 
40 #ifdef __cplusplus
41 }
42 #endif
43 
44 #endif	/* _KERNEL_QUEUE_H */
45