From e18d045b693dfbca1dd40c920d9e4cc3f965b56c Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 25 Jan 2021 16:36:01 -0600 Subject: [PATCH] anv: Refactor anv_queue_finish() By moving vk_object_base_finish() to the end and putting the thread clean-up in an if block we both better mimic anv_queue_init() and have a more correct object destruction order. It comes at the cost of a level of indentation but that seems to actually make the function more clear. Reviewed-by: Lionel Landwerlin Reviewed-by: Jordan Justen Part-of: --- src/intel/vulkan/anv_queue.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index 9a38ca85c9e..5f1db5d154b 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -528,21 +528,20 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue) void anv_queue_finish(struct anv_queue *queue) { + if (queue->device->has_thread_submit) { + pthread_mutex_lock(&queue->mutex); + pthread_cond_broadcast(&queue->cond); + queue->quit = true; + pthread_mutex_unlock(&queue->mutex); + + void *ret; + pthread_join(queue->thread, &ret); + + pthread_cond_destroy(&queue->cond); + pthread_mutex_destroy(&queue->mutex); + } + vk_object_base_finish(&queue->base); - - if (!queue->device->has_thread_submit) - return; - - pthread_mutex_lock(&queue->mutex); - pthread_cond_broadcast(&queue->cond); - queue->quit = true; - pthread_mutex_unlock(&queue->mutex); - - void *ret; - pthread_join(queue->thread, &ret); - - pthread_cond_destroy(&queue->cond); - pthread_mutex_destroy(&queue->mutex); } static VkResult