- works now correctly with job_queue

This commit is contained in:
Martin Willi
2005-11-04 09:37:03 +00:00
parent 16b4690854
commit 4273d819c6
+9 -16
View File
@@ -1,7 +1,7 @@
/** /**
* @file worker.c * @file thread_pool.c
* *
* @brief worker thread, gets jobs form job_queue * @brief Thread-pool with some threads processing the job_queue
* *
*/ */
@@ -54,21 +54,15 @@ typedef struct {
} private_thread_pool_t; } private_thread_pool_t;
pthread_mutex_t muti = PTHREAD_MUTEX_INITIALIZER; void job_processing(private_thread_pool_t *this)
pthread_cond_t condi = PTHREAD_COND_INITIALIZER;
void *job_processing(private_thread_pool_t *this)
{ {
for (;;) { for (;;) {
job_t *job;
job_queue->get(job_queue, &job);
/*job_t *job; /* process them here */
job_queue->get(job_queue, &job);*/
sleep(100); job->destroy(job);
/* flag for termination received ? */
pthread_testcancel();
} }
} }
@@ -87,11 +81,10 @@ static status_t get_pool_size(private_thread_pool_t *this, size_t *size)
static status_t destroy(private_thread_pool_t *this) static status_t destroy(private_thread_pool_t *this)
{ {
int current; int current;
/* flag thread for termination */ /* flag thread for termination */
for (current = 0; current < this->pool_size; current++) { for (current = 0; current < this->pool_size; current++) {
pthread_cancel(this->threads[current]); pthread_cancel(this->threads[current]);
} }
/* wait for all threads */ /* wait for all threads */
for (current = 0; current < this->pool_size; current++) { for (current = 0; current < this->pool_size; current++) {