aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/job_queue.c
diff options
context:
space:
mode:
authorJan Hutter <jhutter@hsr.ch>2005-11-04 10:28:12 +0000
committerJan Hutter <jhutter@hsr.ch>2005-11-04 10:28:12 +0000
commit7c2228f165dc5f9b81f68dd01035beef7b0a99a4 (patch)
tree8335ec0f5db6ffda3c8ed9b08c39b911f4d74038 /Source/charon/job_queue.c
parent4afbee1e5346f1d75c172064a723879f532928d5 (diff)
downloadstrongswan-7c2228f165dc5f9b81f68dd01035beef7b0a99a4.tar.bz2
strongswan-7c2228f165dc5f9b81f68dd01035beef7b0a99a4.tar.xz
- iterator for linked list implemented
- first test for iterator written - linked list values capsulated into private struct
Diffstat (limited to 'Source/charon/job_queue.c')
-rw-r--r--Source/charon/job_queue.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Source/charon/job_queue.c b/Source/charon/job_queue.c
index 783d70de7..e4ab78c2f 100644
--- a/Source/charon/job_queue.c
+++ b/Source/charon/job_queue.c
@@ -85,7 +85,7 @@ struct private_job_queue_s {
status_t get_count(private_job_queue_t *this, int *count)
{
pthread_mutex_lock(&(this->mutex));
- *count = this->list->count;
+ this->list->get_count(this->list,count);
pthread_mutex_unlock(&(this->mutex));
return SUCCESS;
}
@@ -95,13 +95,16 @@ status_t get_count(private_job_queue_t *this, int *count)
*/
status_t get(private_job_queue_t *this, job_t **job)
{
+ int count;
pthread_mutex_lock(&(this->mutex));
// add mutex unlock handler for cancellation
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
// go to wait while no jobs available
- while(this->list->count == 0)
+ this->list->get_count(this->list,&count);
+ while(count == 0)
{
pthread_cond_wait( &(this->condvar), &(this->mutex));
+ this->list->get_count(this->list,&count);
}
// remove mutex-unlock handler (without executing)
pthread_cleanup_pop(0);
@@ -129,7 +132,10 @@ status_t add(private_job_queue_t *this, job_t *job)
*/
status_t job_queue_destroy (private_job_queue_t *this)
{
- while (this->list->count > 0)
+ int count;
+ this->list->get_count(this->list,&count);
+
+ while (count > 0)
{
job_t *job;
if (this->list->remove_first(this->list,(void *) &job) != SUCCESS)
@@ -138,6 +144,7 @@ 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);