wrapped all pthread_rwlock_t in profilable rwlock_t

This commit is contained in:
Martin Willi
2008-11-05 16:12:54 +00:00
parent c1be64eaff
commit 27ed987ef7
8 changed files with 122 additions and 111 deletions
+10 -13
View File
@@ -15,14 +15,11 @@
* $Id$
*/
#define _GNU_SOURCE
#include <pthread.h>
#include "fetcher_manager.h"
#include <debug.h>
#include <utils/linked_list.h>
#include <utils/mutex.h>
#include <utils/linked_list.h>
typedef struct private_fetcher_manager_t private_fetcher_manager_t;
@@ -44,7 +41,7 @@ struct private_fetcher_manager_t {
/**
* read write lock to list
*/
pthread_rwlock_t lock;
rwlock_t *lock;
};
typedef struct {
@@ -74,7 +71,7 @@ static status_t fetch(private_fetcher_manager_t *this,
entry_t *entry;
bool capable = FALSE;
pthread_rwlock_rdlock(&this->lock);
this->lock->read_lock(this->lock);
enumerator = this->fetchers->create_enumerator(this->fetchers);
while (enumerator->enumerate(enumerator, &entry))
{
@@ -132,7 +129,7 @@ static status_t fetch(private_fetcher_manager_t *this,
break;
}
enumerator->destroy(enumerator);
pthread_rwlock_unlock(&this->lock);
this->lock->unlock(this->lock);
if (!capable)
{
DBG1("unable to fetch from %s, no capable fetcher found", url);
@@ -151,9 +148,9 @@ static void add_fetcher(private_fetcher_manager_t *this,
entry->url = strdup(url);
entry->create = create;
pthread_rwlock_wrlock(&this->lock);
this->lock->write_lock(this->lock);
this->fetchers->insert_last(this->fetchers, entry);
pthread_rwlock_unlock(&this->lock);
this->lock->unlock(this->lock);
}
/**
@@ -165,7 +162,7 @@ static void remove_fetcher(private_fetcher_manager_t *this,
enumerator_t *enumerator;
entry_t *entry;
pthread_rwlock_wrlock(&this->lock);
this->lock->write_lock(this->lock);
enumerator = this->fetchers->create_enumerator(this->fetchers);
while (enumerator->enumerate(enumerator, &entry))
{
@@ -176,7 +173,7 @@ static void remove_fetcher(private_fetcher_manager_t *this,
}
}
enumerator->destroy(enumerator);
pthread_rwlock_unlock(&this->lock);
this->lock->unlock(this->lock);
}
/**
@@ -185,7 +182,7 @@ static void remove_fetcher(private_fetcher_manager_t *this,
static void destroy(private_fetcher_manager_t *this)
{
this->fetchers->destroy_function(this->fetchers, (void*)entry_destroy);
pthread_rwlock_destroy(&this->lock);
this->lock->destroy(this->lock);
free(this);
}
@@ -202,7 +199,7 @@ fetcher_manager_t *fetcher_manager_create()
this->public.destroy = (void(*)(fetcher_manager_t*))destroy;
this->fetchers = linked_list_create();
pthread_rwlock_init(&this->lock, NULL);
this->lock = rwlock_create(RWLOCK_DEFAULT);
return &this->public;
}