blob: 84b9b0d99085ea9e834cb63723babe3dfe49bc54 (
plain)
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
|
#ifndef _LOCK_H
#define _LOCK_H
#include <pthread.h>
#include <glib.h>
/* Global */
#define USERNAME_LEN_MAX 33
typedef struct lock {
char id [USERNAME_LEN_MAX];
pthread_mutex_t mutex;
unsigned int instances;
} lock_t;
typedef struct lock_pool {
GHashTable *hash_table;
pthread_mutex_t csec;
} lock_pool_t;
int init_lock_pool (void) __attribute__((warn_unused_result));
void destroy_lock_pool (void);
int get_lock (const char *const username) __attribute__((nonnull));
int release_lock (const char *const username) __attribute__((nonnull));
#endif /* _LOCK_H */
|