int aml_active_sched_num_tasks(struct aml_sched *sched)
{
...;
// Lock queues to get the right count.
pthread_mutex_lock(&s->workq_lock);
pthread_mutex_lock(&s->doneq_lock);
...;
pthread_mutex_unlock(&s->workq_lock);
pthread_mutex_unlock(&s->doneq_lock);
return n;
}
// Wait for any task when calling thread is responsible for progress.
struct aml_task *aml_active_sched_wait_any(struct aml_sched_data *data)
{
...;
pthread_mutex_lock(&(sched->doneq_lock));
...;
pthread_mutex_lock(&(sched->workq_lock));
...;
pthread_mutex_unlock(&(sched->workq_lock));
found_in_doneq:
pthread_mutex_unlock(&(sched->doneq_lock));
return task;
}