Signed-off-by: Jens Axboe <axboe@fb.com>
-static int mutex_timed_out(struct timeval *t, unsigned int seconds)
+static bool mutex_timed_out(struct timeval *t, unsigned int seconds)
{
return mtime_since_now(t) >= seconds * 1000;
}
{
return mtime_since_now(t) >= seconds * 1000;
}
-int fio_mutex_down_trylock(struct fio_mutex *mutex)
+bool fio_mutex_down_trylock(struct fio_mutex *mutex)
assert(mutex->magic == FIO_MUTEX_MAGIC);
pthread_mutex_lock(&mutex->lock);
if (mutex->value) {
mutex->value--;
assert(mutex->magic == FIO_MUTEX_MAGIC);
pthread_mutex_lock(&mutex->lock);
if (mutex->value) {
mutex->value--;
}
pthread_mutex_unlock(&mutex->lock);
}
pthread_mutex_unlock(&mutex->lock);
#define FIO_MUTEX_H
#include <pthread.h>
#define FIO_MUTEX_H
#include <pthread.h>
#define FIO_MUTEX_MAGIC 0x4d555445U
#define FIO_RWLOCK_MAGIC 0x52574c4fU
#define FIO_MUTEX_MAGIC 0x4d555445U
#define FIO_RWLOCK_MAGIC 0x52574c4fU
extern void fio_mutex_remove(struct fio_mutex *);
extern void fio_mutex_up(struct fio_mutex *);
extern void fio_mutex_down(struct fio_mutex *);
extern void fio_mutex_remove(struct fio_mutex *);
extern void fio_mutex_up(struct fio_mutex *);
extern void fio_mutex_down(struct fio_mutex *);
-extern int fio_mutex_down_trylock(struct fio_mutex *);
+extern bool fio_mutex_down_trylock(struct fio_mutex *);
extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int);
extern void fio_rwlock_read(struct fio_rwlock *);
extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int);
extern void fio_rwlock_read(struct fio_rwlock *);