-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
57 lines (47 loc) · 1.24 KB
/
queue.h
File metadata and controls
57 lines (47 loc) · 1.24 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
#ifndef QUEUE_H_
#define QUEUE_H_
/** Elemento della coda.
*
*/
typedef struct Node {
void * data;
struct Node * next;
} Node_t;
/** Struttura dati coda.
*
*/
typedef struct Queue {
Node_t *head;
Node_t *tail;
unsigned long len;
void (*free_data)(void*);
} queue_t;
/** Alloca ed inizializza una coda. Deve essere chiamata da un solo
* thread (tipicamente il thread main).
* \param nrow numero righe
* \param numero colonne
*
* \retval NULL se si sono verificati problemi nell'allocazione (errno settato)
* \retval q puntatore alla coda allocata
*/
queue_t *create_queue(void (*free_data)(void*));
/** Cancella una coda allocata con initQueue. Deve essere chiamata da
* da un solo thread (tipicamente il thread main).
*
* \param q puntatore alla coda da cancellare
*/
void delete_queue(queue_t *q);
/** Inserisce un dato nella coda.
* \param data puntatore al dato da inserire
*
* \retval 0 se successo
* \retval -1 se errore (errno settato opportunamente)
*/
int insert_ele(queue_t *q, void *data);
/** Estrae un dato dalla coda.
*
* \retval data puntatore al dato estratto.
*/
void *take_ele(queue_t *q);
unsigned long length(queue_t *q);
#endif /* QUEUE_H_ */