-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtsqueue.h
More file actions
69 lines (54 loc) · 1.16 KB
/
Copy pathtsqueue.h
File metadata and controls
69 lines (54 loc) · 1.16 KB
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
64
65
66
67
68
69
/*
* =====================================================================================
*
* Filename: tsqueue.h
*
* Description: it's a thread safe queue
*
* Version: 1.0
* Created: 05/09/2012 11:42:42 PM
* Revision: none
* Compiler: gcc
*
* Author: boyce
* Organization: gw
*
* =====================================================================================
*/
#ifndef B_TS_QUEUE_H__
#define B_TS_QUEUE_H__
#ifndef BOOL
#define BOOL int
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ts_queue_item TSQItem;
struct ts_queue_item{
void *data;
struct ts_queue_item *next;
};
typedef struct ts_queue TSQueue;
struct ts_queue{
TSQItem *head;
TSQItem *tail;
pthread_mutex_t lock;
unsigned count;
};
TSQueue *ts_queue_create();
void ts_queue_destroy(TSQueue *cq);
void *ts_queue_deq_data(TSQueue *cq);
int ts_queue_enq_data(TSQueue *cq, void *data);
void *ts_queue_rm_data(TSQueue *cq, void *data);
unsigned ts_queue_count(TSQueue *cq);
BOOL ts_queue_is_empty(TSQueue *cq);
#ifdef __cplusplus
}
#endif
#endif