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!
This commit is contained in:
@@ -175,6 +175,7 @@ void BLI_thread_queue_push(ThreadQueue *queue, void *work);
|
||||
void *BLI_thread_queue_pop(ThreadQueue *queue);
|
||||
void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms);
|
||||
int BLI_thread_queue_size(ThreadQueue *queue);
|
||||
bool BLI_thread_queue_is_empty(ThreadQueue *queue);
|
||||
|
||||
void BLI_thread_queue_wait_finish(ThreadQueue *queue);
|
||||
void BLI_thread_queue_nowait(ThreadQueue *queue);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user