-
Notifications
You must be signed in to change notification settings - Fork 0
/
deque.h
50 lines (36 loc) · 826 Bytes
/
deque.h
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
#ifndef DEQUE_H
#define DEQUE_H
#include <stdbool.h>
#include <stdatomic.h>
struct taskArgs {
int* nodeRefs;
int nFrags;
int nodeIndex;
atomic_int* nextNode;
atomic_int* nextFragment;
atomic_int* nextRef;
atomic_int* nObj;
atomic_int* nSpat;
struct BVHNode* nodes;
struct Fragment* fragments;
int* references;
};
typedef struct taskArgs taskArgs;
struct node {
taskArgs data;
struct node* next;
struct node* prev;
};
typedef struct node node;
struct deque {
node* sentinel;
pthread_mutex_t lock;
};
typedef struct deque deque;
deque* newDeque(void);
bool tryPopLeft(deque* q, taskArgs* res);
bool tryPopRight(deque* q, taskArgs* res);
void pushLeft(deque* q, taskArgs data);
void pushRight(deque* q, taskArgs data);
void freeDeque(deque* q);
#endif