- cancelation points defined
This commit is contained in:
@@ -166,6 +166,7 @@ static status_t get(private_event_queue_t *this, job_t **job)
|
|||||||
timeval_t current_time;
|
timeval_t current_time;
|
||||||
event_t * next_event;
|
event_t * next_event;
|
||||||
int count;
|
int count;
|
||||||
|
int oldstate;
|
||||||
|
|
||||||
pthread_mutex_lock(&(this->mutex));
|
pthread_mutex_lock(&(this->mutex));
|
||||||
|
|
||||||
@@ -174,11 +175,21 @@ static status_t get(private_event_queue_t *this, job_t **job)
|
|||||||
this->list->get_count(this->list,&count);
|
this->list->get_count(this->list,&count);
|
||||||
while(count == 0)
|
while(count == 0)
|
||||||
{
|
{
|
||||||
|
/* add mutex unlock handler for cancellation, enable cancellation */
|
||||||
|
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
|
||||||
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
||||||
|
|
||||||
pthread_cond_wait( &(this->condvar), &(this->mutex));
|
pthread_cond_wait( &(this->condvar), &(this->mutex));
|
||||||
|
|
||||||
|
/* 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->get_count(this->list,&count);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->list->get_first(this->list,(void **) &next_event);
|
this->list->get_first(this->list,(void **) &next_event);
|
||||||
|
|
||||||
gettimeofday(¤t_time,NULL);
|
gettimeofday(¤t_time,NULL);
|
||||||
long difference = time_difference(¤t_time,&(next_event->time));
|
long difference = time_difference(¤t_time,&(next_event->time));
|
||||||
if (difference <= 0)
|
if (difference <= 0)
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ static status_t get(private_job_queue_t *this, job_t **job)
|
|||||||
/* add mutex unlock handler for cancellation, enable cancellation */
|
/* add mutex unlock handler for cancellation, enable cancellation */
|
||||||
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
|
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
||||||
|
|
||||||
pthread_cond_wait( &(this->condvar), &(this->mutex));
|
pthread_cond_wait( &(this->condvar), &(this->mutex));
|
||||||
|
|
||||||
/* reset cancellation, remove mutex-unlock handler (without executing) */
|
/* reset cancellation, remove mutex-unlock handler (without executing) */
|
||||||
|
|||||||
Reference in New Issue
Block a user