wrapped all pthread_rwlock_t in profilable rwlock_t
This commit is contained in:
@@ -15,17 +15,18 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
#include <library.h>
|
||||
#include <debug.h>
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
#include <library.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_mutex_t private_mutex_t;
|
||||
typedef struct private_r_mutex_t private_r_mutex_t;
|
||||
typedef struct private_condvar_t private_condvar_t;
|
||||
@@ -440,6 +441,14 @@ static void write_lock(private_rwlock_t *this)
|
||||
profiler_end(&this->profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of rwlock_t.try_write_lock
|
||||
*/
|
||||
static bool try_write_lock(private_rwlock_t *this)
|
||||
{
|
||||
return pthread_rwlock_trywrlock(&this->rwlock) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of rwlock_t.unlock
|
||||
*/
|
||||
@@ -472,6 +481,7 @@ rwlock_t *rwlock_create(rwlock_type_t type)
|
||||
|
||||
this->public.read_lock = (void(*)(rwlock_t*))read_lock;
|
||||
this->public.write_lock = (void(*)(rwlock_t*))write_lock;
|
||||
this->public.try_write_lock = (bool(*)(rwlock_t*))try_write_lock;
|
||||
this->public.unlock = (void(*)(rwlock_t*))rw_unlock;
|
||||
this->public.destroy = (void(*)(rwlock_t*))rw_destroy;
|
||||
|
||||
|
||||
@@ -129,6 +129,15 @@ struct rwlock_t {
|
||||
*/
|
||||
void (*write_lock)(rwlock_t *this);
|
||||
|
||||
/**
|
||||
* Try to acquire the write lock.
|
||||
*
|
||||
* Never blocks, but returns FALSE if the lock was already occupied.
|
||||
*
|
||||
* @return TRUE if lock acquired
|
||||
*/
|
||||
bool (*try_write_lock)(rwlock_t *this);
|
||||
|
||||
/**
|
||||
* Release any acquired lock.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user