-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.h
44 lines (29 loc) · 845 Bytes
/
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
#ifndef TPOOL_QUEUE_H
#define TPOOL_QUEUE_H
#include <stdlib.h>
#include <stdbool.h>
typedef struct tpool_list {
size_t alloc_size;
size_t count;
void **data;
} tpool_list;
typedef struct tpool_queue {
pthread_mutex_t body_mutex;
tpool_list in;
tpool_list out;
size_t count;
pthread_mutex_t new_mut;
pthread_cond_t new_cond;
bool unblock;
} tpool_queue;
void tpool_list_init(tpool_list *list);
void tpool_list_free(tpool_list *list);
void tpool_list_push(tpool_list *list, void *item);
void *tpool_list_pop(tpool_list *list);
tpool_queue *tpool_queue_init();
void tpool_queue_free(tpool_queue *queue);
void tpool_enqueue(tpool_queue *queue, void *item);
void tpool_queue_unblock(tpool_queue *queue);
void tpool_queue_wait(tpool_queue *queue);
void *tpool_dequeue(tpool_queue *queue);
#endif