forked from wazuh/wazuh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue_op.h
More file actions
39 lines (34 loc) · 1.02 KB
/
queue_op.h
File metadata and controls
39 lines (34 loc) · 1.02 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
/*
* Queue (abstract data type)
* Copyright (C) 2015-2019, Wazuh Inc.
* October 2, 2017
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation.
*/
#ifndef QUEUE_OP_H
#define QUEUE_OP_H
#include <pthread.h>
typedef struct queue_t {
void ** data;
size_t begin;
size_t end;
size_t size;
pthread_mutex_t mutex;
pthread_cond_t available;
pthread_cond_t available_not_empty;
unsigned int elements;
} w_queue_t;
w_queue_t * queue_init(size_t n);
void queue_free(w_queue_t * queue);
int queue_full(const w_queue_t * queue);
int queue_empty(const w_queue_t * queue);
int queue_push(w_queue_t * queue, void * data);
int queue_push_ex(w_queue_t * queue, void * data);
int queue_push_ex_block(w_queue_t * queue, void * data);
void * queue_pop(w_queue_t * queue);
void * queue_pop_ex(w_queue_t * queue);
void * queue_pop_ex_block(w_queue_t * queue);
#endif // QUEUE_OP_H