-
Notifications
You must be signed in to change notification settings - Fork 1
/
queue.h
64 lines (51 loc) · 1.22 KB
/
queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef QUEUE_H
#define QUEUE_H
/*
* Queue - the abstract type of a concurrent queue.
*/
typedef struct QueueStruct Queue;
/*
* queue_alloc:
*
* Allocate a concurrent queue of a specific size.
*
*/
Queue *queue_alloc(int size);
/*
* queue_free:
*
* Free a concurrent queue and associated memory.
* NOTE: A user should not free a queue until any
* users are finished. Any calling queue_free() while
* any consumer/producer is waiting on queue_put or queue_get
* will cause queue_free to print an error and exit the program.
*
*/
void queue_free(Queue *queue);
/*
* queue_put:
*
* Place an item into the concurrent queue.
*
* If there is no space available then queue_put will
* block until a space becomes available when it will
* put the item into the queue and immediately return.
*
* Uses void* to hold an arbitrary type of item,
* it is the users responsibility to manage memory
* and ensure it is correctly typed.
*
*/
void enqueue(Queue *queue, void *item);
/*
* queue_get:
*
* Get an item from the concurrent queue.
*
* If there is no item available then queue_get
* will block until an item becomes avaible when
* it will immediately return that item.
*
*/
void *dequeue(Queue *queue);
#endif