-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathqueue.h
More file actions
34 lines (26 loc) · 716 Bytes
/
queue.h
File metadata and controls
34 lines (26 loc) · 716 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
32
33
34
#ifndef MEMLINK_QUEUE_H
#define MEMLINK_QUEUE_H
#include <stdio.h>
#include "wthread.h"
#define MEMLINK_QUEUE_MAX_FREE 1000
typedef struct _queue_item
{
Conn *conn;
struct _queue_item *next;
}QueueItem;
typedef struct _queue
{
QueueItem *head;
QueueItem *tail;
pthread_mutex_t lock;
QueueItem *freelist;
int maxfree;
}Queue;
Queue* queue_create();
void queue_destroy(Queue *q);
int queue_size(Queue *q);
int queue_append(Queue *q, Conn *conn);
int queue_remove_last(Queue *q, Conn *conn);
QueueItem* queue_get(Queue *q);
void queue_free(Queue *q, QueueItem *item);
#endif