-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockingQueue.h
More file actions
30 lines (19 loc) · 796 Bytes
/
BlockingQueue.h
File metadata and controls
30 lines (19 loc) · 796 Bytes
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
#ifndef _BLOCKING_QUEUE_H_
#define _BLOCKING_QUEUE_H_
#include <stdint.h>
/**
* We define a blocking queue data structure with a bound
* on the number of entries. This data structure takes care
* of its own synchronization internally. The add operation
* blocks if the queue is full, and the remove operation
* blocks if the queue is empty. Obviously it's FIFO.
*/
#define QUEUE_SIZE 1024
typedef struct BlockingQueueStruct BlockingQueue;
BlockingQueue *BlockingQueue_create();
void BlockingQueue_destroy(BlockingQueue *q);
void BlockingQueue_add(BlockingQueue *q, void *entry);
void *BlockingQueue_remove(BlockingQueue *q);
void *BlockingQueue_tryRemove(BlockingQueue *q);
void *BlockingQueue_timedRemove(BlockingQueue *q, uint32_t milliseconds);
#endif /* _BLOCKING_QUEUE_H_ */