dispatch: wakeup only if needed on mp_dispatch_resume()

The wakeup is needed to make mp_dispatch_queue_process() return if
suspension is not needed anymore - which is only the case when the
request count reaches 0.

The assertion added with this commit always has/had to be true.
This commit is contained in:
wm4 2014-04-24 01:03:05 +02:00
parent 2f7cef117a
commit f5df78b3fc
1 changed files with 3 additions and 1 deletions

View File

@ -238,9 +238,11 @@ void mp_dispatch_suspend(struct mp_dispatch_queue *queue)
void mp_dispatch_resume(struct mp_dispatch_queue *queue)
{
pthread_mutex_lock(&queue->lock);
assert(queue->suspended);
assert(queue->suspend_requested > 0);
queue->suspend_requested--;
pthread_cond_broadcast(&queue->cond);
if (queue->suspend_requested == 0)
pthread_cond_broadcast(&queue->cond);
pthread_mutex_unlock(&queue->lock);
}