From edde8442f57e714a5d8439d596bceb12ac20e42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sun, 7 Jul 2013 00:30:26 +0200 Subject: [PATCH] Added parallelQueueWait --- src/rendering/tools/parallel.c | 8 ++++++++ src/rendering/tools/parallel.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/rendering/tools/parallel.c b/src/rendering/tools/parallel.c index a06296a..f72156c 100644 --- a/src/rendering/tools/parallel.c +++ b/src/rendering/tools/parallel.c @@ -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) { if (queue->stopping) diff --git a/src/rendering/tools/parallel.h b/src/rendering/tools/parallel.h index 98613e7..150c339 100644 --- a/src/rendering/tools/parallel.h +++ b/src/rendering/tools/parallel.h @@ -75,6 +75,14 @@ void parallelQueueDelete(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. *