-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlqueue.h
More file actions
46 lines (34 loc) · 1.16 KB
/
lqueue.h
File metadata and controls
46 lines (34 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
#pragma once
/*
* lqueue.h -- public interface to the queue module
*/
#include <pthread.h>
#include "queue.h"
struct lockedQ {
pthread_mutex_t lock;
queue_t *queue;
};
/* the queue representation is hidden from users of the module */
typedef void lqueue_t;
/* create an empty queue */
lqueue_t* lqopen(void);
/* deallocate a queue, frees everything in it */
void lqclose(lqueue_t *qp);
/* put element at end of queue */
int lqput(lqueue_t *qp, void *elementp);
/* get first element from queue */
void* lqget(lqueue_t *qp);
/* apply a void function to every element of a queue */
void lqapply(lqueue_t *qp, void (*fn)(void* elementp));
/* search a queue using a supplied boolean function, returns an element */
void* lqsearch(lqueue_t *qp,
int (*searchfn)(void* elementp,const void* keyp),
const void* skeyp);
/* search a queue using a supplied boolean function, removes and
* returns the element
*/
void* lqremove(lqueue_t *qp,
int (*searchfn)(void* elementp,const void* keyp),
const void* skeyp);
/* concatenatenates elements of q2 into q1, q2 is dealocated upon completion */
void lqconcat(lqueue_t *q1p, lqueue_t *q2p);