-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
32 lines (26 loc) · 626 Bytes
/
queue.h
File metadata and controls
32 lines (26 loc) · 626 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
#pragma ONCE
#include <pthread.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdatomic.h>
#define buff_size 500000000
typedef struct node
{
struct node* next;
unsigned value;
} node_t;
typedef struct
{
char buffer[ buff_size ];
atomic_uint writers;
atomic_uint readers;
} library;
typedef struct queue
{
node_t* head;
atomic_uint size;
} queue_t;
void queue_add_read_thread(pthread_mutex_t**, queue_t*, pthread_cond_t**, library*, unsigned);
void queue_add(pthread_mutex_t**, queue_t*, unsigned);
void queue_remove(pthread_mutex_t**, queue_t*, unsigned);
bool queue_empty(queue_t*);