-
Notifications
You must be signed in to change notification settings - Fork 2
/
dreadlock.h
52 lines (36 loc) · 1.01 KB
/
dreadlock.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
51
52
#ifndef DREADLOCK_H
#define DREADLOCK_H
#include "utlist.h"
#include "uthash.h"
typedef struct dreadlock_timer {
double wake_at;
Rendez *wake;
struct dreadlock_timer *prev;
struct dreadlock_timer *next;
} dreadlock_timer;
typedef struct dreadlock_claimant {
unsigned int id;
int won;
Rendez wait;
struct dreadlock_claimant *prev;
struct dreadlock_claimant *next;
} dreadlock_claimant;
typedef struct dreadlock_lock {
char *key;
dreadlock_claimant *waits;
UT_hash_handle hh;
} dreadlock_lock;
typedef struct dreadlock_user_lock {
dreadlock_claimant *wait;
dreadlock_lock *lock;
UT_hash_handle hh;
} dreadlock_user_lock;
typedef struct dreadlock_client_state {
char id[500];
int fd;
dreadlock_user_lock *locks;
} dreadlock_client_state;
void do_lock(dreadlock_client_state *st, char *key, int len, int timeout_ms);
void do_unlock(dreadlock_client_state *st, char *key, int len);
void ragel_parse(dreadlock_client_state *st);
#endif /* DREADLOCK_H */