diff options
Diffstat (limited to 'Source/charon/job_queue.c')
-rw-r--r-- | Source/charon/job_queue.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Source/charon/job_queue.c b/Source/charon/job_queue.c index b5c21e6b2..aeb0da950 100644 --- a/Source/charon/job_queue.c +++ b/Source/charon/job_queue.c @@ -60,12 +60,13 @@ struct private_job_queue_s { /** * @brief implements function get_count of job_queue_t */ -static status_t get_count(private_job_queue_t *this, int *count) +static int get_count(private_job_queue_t *this) { + int count; pthread_mutex_lock(&(this->mutex)); - this->list->get_count(this->list,count); + count = this->list->get_count(this->list); pthread_mutex_unlock(&(this->mutex)); - return SUCCESS; + return count; } /** @@ -73,12 +74,10 @@ static status_t get_count(private_job_queue_t *this, int *count) */ static status_t get(private_job_queue_t *this, job_t **job) { - int count; int oldstate; pthread_mutex_lock(&(this->mutex)); /* go to wait while no jobs available */ - this->list->get_count(this->list,&count); - while(count == 0) + while(this->list->get_count(this->list) == 0) { /* add mutex unlock handler for cancellation, enable cancellation */ pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex)); @@ -89,7 +88,6 @@ static status_t get(private_job_queue_t *this, job_t **job) /* reset cancellation, remove mutex-unlock handler (without executing) */ pthread_setcancelstate(oldstate, NULL); pthread_cleanup_pop(0); - this->list->get_count(this->list,&count); } this->list->remove_first(this->list,(void **) job); pthread_mutex_unlock(&(this->mutex)); @@ -114,10 +112,7 @@ static status_t add(private_job_queue_t *this, job_t *job) */ static status_t job_queue_destroy (private_job_queue_t *this) { - int count; - this->list->get_count(this->list,&count); - - while (count > 0) + while (this->list->get_count(this->list) > 0) { job_t *job; if (this->list->remove_first(this->list,(void *) &job) != SUCCESS) @@ -126,7 +121,6 @@ static status_t job_queue_destroy (private_job_queue_t *this) break; } job->destroy(job); - this->list->get_count(this->list,&count); } this->list->destroy(this->list); @@ -157,7 +151,7 @@ job_queue_t *job_queue_create() return NULL; } - this->public.get_count = (status_t(*)(job_queue_t*, int*))get_count; + this->public.get_count = (int(*)(job_queue_t*))get_count; this->public.get = (status_t(*)(job_queue_t*, job_t**))get; this->public.add = (status_t(*)(job_queue_t*, job_t*))add; this->public.destroy = (status_t(*)(job_queue_t*))job_queue_destroy; |