- works now correctly with job_queue
This commit is contained in:
@@ -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,7 +81,6 @@ 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]);
|
||||||
|
|||||||
Reference in New Issue
Block a user