mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-28 03:34:06 +00:00
Drop an unnecessary pthread_cond_broadcast
Drop pthread_cond_broadcast on threadqueue->cond in function kvz_threadqueue_waitfor. The broadcast caused threads to be woken up more often than necessary.
This commit is contained in:
parent
20d6444f07
commit
4fc9b743c1
|
@ -443,25 +443,18 @@ int kvz_threadqueue_finalize(threadqueue_queue_t * const threadqueue)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvz_threadqueue_waitfor(threadqueue_queue_t * const threadqueue, threadqueue_job_t * const job) {
|
int kvz_threadqueue_waitfor(threadqueue_queue_t * const threadqueue, threadqueue_job_t * const job)
|
||||||
int job_done = 0;
|
{
|
||||||
|
// NULL job is clearly OK.
|
||||||
//NULL job is clearly OK :-)
|
|
||||||
if (!job) return 1;
|
if (!job) return 1;
|
||||||
|
|
||||||
//Lock the queue
|
|
||||||
PTHREAD_LOCK(&threadqueue->lock);
|
|
||||||
do {
|
|
||||||
|
|
||||||
PTHREAD_LOCK(&job->lock);
|
PTHREAD_LOCK(&job->lock);
|
||||||
job_done = (job->state == THREADQUEUE_JOB_STATE_DONE);
|
while (job->state != THREADQUEUE_JOB_STATE_DONE) {
|
||||||
|
PTHREAD_COND_WAIT(&threadqueue->cb_cond, &job->lock);
|
||||||
|
}
|
||||||
PTHREAD_UNLOCK(&job->lock);
|
PTHREAD_UNLOCK(&job->lock);
|
||||||
|
|
||||||
if (!job_done) {
|
PTHREAD_LOCK(&threadqueue->lock);
|
||||||
PTHREAD_COND_BROADCAST(&(threadqueue->cond));
|
|
||||||
PTHREAD_COND_WAIT(&threadqueue->cb_cond, &threadqueue->lock);
|
|
||||||
}
|
|
||||||
} while (!job_done);
|
|
||||||
|
|
||||||
// Free jobs submitted before this job.
|
// Free jobs submitted before this job.
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
Loading…
Reference in a new issue