GCS  0.2.3
gu_fifo.h
1 /*
2  * Copyright (C) 2008-2013 Codership Oy <info@codership.com>
3  *
4  * Queue (FIFO) class definition
5  *
6  * The driving idea behind this class is avoiding malloc()'s
7  * at all costs on one hand, on the other - make it almost
8  * as infinite as an ordinary linked list. FIFO properties
9  * help to achieve that.
10  *
11  * When needed this FIFO can be made very big, holding
12  * millions or even billions of items while taking up
13  * minimum space when there are few items in the queue.
14  * malloc()'s do happen, but once per thousand of pushes and
15  * allocate multiples of pages, thus reducing memory fragmentation.
16  */
17 
18 #ifndef _gu_fifo_h_
19 #define _gu_fifo_h_
20 
21 #include <errno.h>
22 
23 typedef struct gu_fifo gu_fifo_t;
24 
26 extern gu_fifo_t* gu_fifo_create (size_t length, size_t unit);
28 extern void gu_fifo_close (gu_fifo_t *queue);
30 extern void gu_fifo_open (gu_fifo_t *queue);
32 extern void gu_fifo_destroy (gu_fifo_t *queue);
34 extern char* gu_fifo_print (gu_fifo_t *queue);
35 
37 extern void gu_fifo_lock (gu_fifo_t *q);
39 extern void gu_fifo_release (gu_fifo_t *q);
45 extern void* gu_fifo_get_head (gu_fifo_t* q, int* err);
47 extern void gu_fifo_pop_head (gu_fifo_t* q);
49 extern void* gu_fifo_get_tail (gu_fifo_t* q);
51 extern void gu_fifo_push_tail (gu_fifo_t* q);
53 extern long gu_fifo_length (gu_fifo_t* q);
55 extern void gu_fifo_stats_get (gu_fifo_t* q, int* q_len, double* q_len_avg);
57 extern void gu_fifo_stats_flush(gu_fifo_t* q);
58 
60 extern int gu_fifo_cancel_gets (gu_fifo_t* q);
62 extern int gu_fifo_resume_gets (gu_fifo_t* q);
63 
64 #endif // _gu_fifo_h_
Definition: gu_fifo.c:31