-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlockref.h
More file actions
executable file
·34 lines (27 loc) · 810 Bytes
/
Copy pathlockref.h
File metadata and controls
executable file
·34 lines (27 loc) · 810 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 LOCKREF_6cefa1704dbb_H
#define LOCKREF_6cefa1704dbb_H
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
struct lockref
{
pthread_mutex_t lock;
int count;
};
extern void util_lockref_init(struct lockref *lockref, int c);
extern void util_lockref_fini(struct lockref *lockref);
extern void util_lockref_get(struct lockref *lockref);
extern int util_lockref_get_not_dead(struct lockref *lockref);
extern void util_lockref_mark_dead(struct lockref *lockref);
extern int util_lockref_put_not_zero(struct lockref *lockref);
extern int util_lockref_put_or_lock(struct lockref *lockref);
/* Must be called under spinlock for reliable results */
static inline int __util_lockref_is_dead(const struct lockref *l)
{
return ((int)l->count < 0);
}
#ifdef __cplusplus
}
#endif
#endif