mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Tentative fix for race condition
This commit is contained in:
parent
b194e19708
commit
68ad323e84
|
@ -42,7 +42,6 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
|
|||
|
||||
for(;;) {
|
||||
int i = 0;
|
||||
int signal_count = 0;
|
||||
threadqueue_job * job_to_run = NULL;
|
||||
|
||||
PTHREAD_LOCK(&threadqueue->lock);
|
||||
|
@ -88,6 +87,7 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
|
|||
|
||||
//Ok we got a job (and we have a lock on it)
|
||||
if (job_to_run) {
|
||||
int queue_waiting_dependency_decr, queue_waiting_execution_incr;
|
||||
threadqueue_job * const job = job_to_run;
|
||||
|
||||
assert(job->state == THREADQUEUE_JOB_STATE_QUEUED || (job == next_job && job->state == THREADQUEUE_JOB_STATE_RUNNING));
|
||||
|
@ -121,9 +121,10 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
|
|||
|
||||
job->state = THREADQUEUE_JOB_STATE_DONE;
|
||||
|
||||
signal_count = 0;
|
||||
next_job = NULL;
|
||||
|
||||
queue_waiting_dependency_decr = 0;
|
||||
queue_waiting_execution_incr = 0;
|
||||
//Decrease counter of dependencies
|
||||
for (i = 0; i < job->rdepends_count; ++i) {
|
||||
threadqueue_job * const depjob = job->rdepends[i];
|
||||
|
@ -139,11 +140,9 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
|
|||
next_job = depjob;
|
||||
depjob->state = THREADQUEUE_JOB_STATE_RUNNING;
|
||||
} else {
|
||||
++signal_count;
|
||||
++threadqueue->queue_waiting_execution;
|
||||
++queue_waiting_execution_incr;
|
||||
}
|
||||
assert(threadqueue->queue_waiting_dependency > 0);
|
||||
--threadqueue->queue_waiting_dependency;
|
||||
++queue_waiting_dependency_decr;
|
||||
}
|
||||
|
||||
PTHREAD_UNLOCK(&depjob->lock);
|
||||
|
@ -153,9 +152,11 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
|
|||
|
||||
//Signal the queue that we've done a job
|
||||
PTHREAD_LOCK(&threadqueue->lock);
|
||||
for (i = 0; i < signal_count; ++i) {
|
||||
PTHREAD_COND_SIGNAL(&threadqueue->cond);
|
||||
}
|
||||
assert(threadqueue->queue_waiting_dependency >= queue_waiting_dependency_decr);
|
||||
threadqueue->queue_waiting_dependency -= queue_waiting_dependency_decr;
|
||||
threadqueue->queue_waiting_execution += queue_waiting_execution_incr;
|
||||
PTHREAD_COND_BROADCAST(&threadqueue->cond);
|
||||
|
||||
//PTHREAD_COND_BROADCAST(&threadqueue->cond);
|
||||
//Don't log this one
|
||||
//PTHREAD_COND_SIGNAL(&threadqueue->cb_cond);
|
||||
|
|
Loading…
Reference in a new issue