Migrated fetcher_manager to INIT/METHOD macros
This commit is contained in:
@@ -58,11 +58,8 @@ static void entry_destroy(entry_t *entry)
|
|||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(fetcher_manager_t, fetch, status_t,
|
||||||
* Implementation of fetcher_manager_t.fetch.
|
private_fetcher_manager_t *this, char *url, chunk_t *response, ...)
|
||||||
*/
|
|
||||||
static status_t fetch(private_fetcher_manager_t *this,
|
|
||||||
char *url, chunk_t *response, ...)
|
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
status_t status = NOT_SUPPORTED;
|
status_t status = NOT_SUPPORTED;
|
||||||
@@ -139,27 +136,22 @@ static status_t fetch(private_fetcher_manager_t *this,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(fetcher_manager_t, add_fetcher, void,
|
||||||
* Implementation of fetcher_manager_t.add_fetcher.
|
private_fetcher_manager_t *this, fetcher_constructor_t create, char *url)
|
||||||
*/
|
|
||||||
static void add_fetcher(private_fetcher_manager_t *this,
|
|
||||||
fetcher_constructor_t create, char *url)
|
|
||||||
{
|
{
|
||||||
entry_t *entry = malloc_thing(entry_t);
|
entry_t *entry;
|
||||||
|
|
||||||
entry->url = strdup(url);
|
|
||||||
entry->create = create;
|
|
||||||
|
|
||||||
|
INIT(entry,
|
||||||
|
.url = strdup(url),
|
||||||
|
.create = create,
|
||||||
|
);
|
||||||
this->lock->write_lock(this->lock);
|
this->lock->write_lock(this->lock);
|
||||||
this->fetchers->insert_last(this->fetchers, entry);
|
this->fetchers->insert_last(this->fetchers, entry);
|
||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(fetcher_manager_t, remove_fetcher, void,
|
||||||
* Implementation of fetcher_manager_t.remove_fetcher.
|
private_fetcher_manager_t *this, fetcher_constructor_t create)
|
||||||
*/
|
|
||||||
static void remove_fetcher(private_fetcher_manager_t *this,
|
|
||||||
fetcher_constructor_t create)
|
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -178,10 +170,8 @@ static void remove_fetcher(private_fetcher_manager_t *this,
|
|||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(fetcher_manager_t, destroy, void,
|
||||||
* Implementation of fetcher_manager_t.destroy
|
private_fetcher_manager_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_fetcher_manager_t *this)
|
|
||||||
{
|
{
|
||||||
this->fetchers->destroy_function(this->fetchers, (void*)entry_destroy);
|
this->fetchers->destroy_function(this->fetchers, (void*)entry_destroy);
|
||||||
this->lock->destroy(this->lock);
|
this->lock->destroy(this->lock);
|
||||||
@@ -193,15 +183,18 @@ static void destroy(private_fetcher_manager_t *this)
|
|||||||
*/
|
*/
|
||||||
fetcher_manager_t *fetcher_manager_create()
|
fetcher_manager_t *fetcher_manager_create()
|
||||||
{
|
{
|
||||||
private_fetcher_manager_t *this = malloc_thing(private_fetcher_manager_t);
|
private_fetcher_manager_t *this;
|
||||||
|
|
||||||
this->public.fetch = (status_t(*)(fetcher_manager_t*, char *url, chunk_t *response, ...))fetch;
|
INIT(this,
|
||||||
this->public.add_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t,char*))add_fetcher;
|
.public = {
|
||||||
this->public.remove_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t))remove_fetcher;
|
.fetch = _fetch,
|
||||||
this->public.destroy = (void(*)(fetcher_manager_t*))destroy;
|
.add_fetcher = _add_fetcher,
|
||||||
|
.remove_fetcher = _remove_fetcher,
|
||||||
this->fetchers = linked_list_create();
|
.destroy = _destroy,
|
||||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
},
|
||||||
|
.fetchers = linked_list_create(),
|
||||||
|
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user