Rework lockfile= file lock handling
[fio.git] / mutex.h
... / ...
CommitLineData
1#ifndef FIO_MUTEX_H
2#define FIO_MUTEX_H
3
4#include <pthread.h>
5
6struct fio_mutex {
7 pthread_mutex_t lock;
8 pthread_cond_t cond;
9 int value;
10 int waiters;
11};
12
13struct fio_rwlock {
14 pthread_rwlock_t lock;
15};
16
17enum {
18 FIO_MUTEX_LOCKED = 0,
19 FIO_MUTEX_UNLOCKED = 1,
20};
21
22extern struct fio_mutex *fio_mutex_init(int);
23extern void fio_mutex_remove(struct fio_mutex *);
24extern void fio_mutex_up(struct fio_mutex *);
25extern void fio_mutex_down(struct fio_mutex *);
26extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int);
27
28extern void fio_rwlock_read(struct fio_rwlock *);
29extern void fio_rwlock_write(struct fio_rwlock *);
30extern void fio_rwlock_unlock(struct fio_rwlock *);
31extern struct fio_rwlock *fio_rwlock_init(void);
32extern void fio_rwlock_remove(struct fio_rwlock *);
33
34#endif