Added parallelQueueWait

This commit is contained in:
Michaël Lemaire 2013-07-07 00:30:26 +02:00
parent 8c8fb185cd
commit edde8442f5
2 changed files with 16 additions and 0 deletions

View file

@ -292,6 +292,14 @@ void parallelQueueInterrupt(ParallelQueue* queue)
} }
} }
void parallelQueueWait(ParallelQueue* queue)
{
while (queue->jobs_count > 0)
{
timeSleepMs(100);
}
}
int parallelQueueAddJob(ParallelQueue* queue, FuncParallelJob func_process, void* data) int parallelQueueAddJob(ParallelQueue* queue, FuncParallelJob func_process, void* data)
{ {
if (queue->stopping) if (queue->stopping)

View file

@ -75,6 +75,14 @@ void parallelQueueDelete(ParallelQueue* queue);
*/ */
void parallelQueueInterrupt(ParallelQueue* queue); void parallelQueueInterrupt(ParallelQueue* queue);
/**
* Wait for all jobs to finish.
*
* This function will return as soon as there is no pending jobs. It is recommended to stop feeding the queue, or this
* function may never return.
*/
void parallelQueueWait(ParallelQueue* queue);
/** /**
* Add a job to the queue. * Add a job to the queue.
* *