diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-19 13:30:21 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-19 13:31:26 +0300 |
commit | 0f171d4a2599f9c8d1205e319de1024bf030f762 (patch) | |
tree | 7119054e9abb18cd01fca2d3fab594c0df36e1cd /source/blender/blenlib/intern | |
parent | 1cf1f4889344528a4b16c0f5434342321d5ca13c (diff) |
BLI_threads Queue: add `BLI_thread_queue_is_empty()`.
Avoids counting the whole queue when we only want to check whether it is empty or not!
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 50295954192..73cadea71c0 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -777,6 +777,17 @@ int BLI_thread_queue_size(ThreadQueue *queue) return size; } +bool BLI_thread_queue_is_empty(ThreadQueue *queue) +{ + bool is_empty; + + pthread_mutex_lock(&queue->mutex); + is_empty = BLI_gsqueue_is_empty(queue->queue); + pthread_mutex_unlock(&queue->mutex); + + return is_empty; +} + void BLI_thread_queue_nowait(ThreadQueue *queue) { pthread_mutex_lock(&queue->mutex); |