-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlf_queue.h
More file actions
executable file
·54 lines (44 loc) · 977 Bytes
/
Copy pathlf_queue.h
File metadata and controls
executable file
·54 lines (44 loc) · 977 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Description: lock free queue, for mulit process or thread read and write
* History: [email protected], 2013/03/06, create
*/
# pragma once
# ifdef __cplusplus
extern "C" {
# endif
# include <stdint.h>
# include <sys/types.h>
typedef void * lf_queue;
/*
* pragma:
* shm_key: 不为 0 使用共享内存,否则使用 malloc 获取内存
* unit_size: 数据单元长度
* max_unit_num: 队列最大长度
* return:
* < 0: error
* == 0: success
*/
int lf_queue_init(lf_queue *queue, key_t shm_key, int32_t unit_size, int32_t max_unit_num);
/*
* return:
* < -1: error
* == -1: full
* == 0: success
*/
int lf_queue_push(lf_queue queue, void *unit);
/*
* return:
* < -1: error
* == -1: empty
* == 0: success
*/
int lf_queue_pop(lf_queue queue, void *unit);
/*
* return:
* < 0: error
* >= 0: len
*/
int lf_queue_len(lf_queue queue);
# ifdef __cplusplus
}
# endif