layers: threading - use std mutex
Change-Id: I773ea148807e5b634ad021ea58b001cd3d1bad87
diff --git a/layers/threading.cpp b/layers/threading.cpp
index 5138184..d23c9ff 100644
--- a/layers/threading.cpp
+++ b/layers/threading.cpp
@@ -48,12 +48,6 @@
static void initThreading(layer_data *my_data, const VkAllocationCallbacks *pAllocator) {
layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "google_threading");
-
- if (!threadingLockInitialized) {
- loader_platform_thread_create_mutex(&threadingLock);
- loader_platform_thread_init_cond(&threadingCond);
- threadingLockInitialized = 1;
- }
}
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
@@ -102,12 +96,6 @@
layer_debug_report_destroy_instance(my_data->report_data);
delete my_data->instance_dispatch_table;
layer_data_map.erase(key);
-
- if (layer_data_map.empty()) {
- // Release mutex when destroying last instance.
- loader_platform_thread_delete_mutex(&threadingLock);
- threadingLockInitialized = 0;
- }
}
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
@@ -311,9 +299,8 @@
// Record mapping from command buffer to command pool
if (VK_SUCCESS == result) {
for (uint32_t index = 0; index < pAllocateInfo->commandBufferCount; index++) {
- loader_platform_thread_lock_mutex(&threadingLock);
+ std::lock_guard<std::mutex> lock(global_lock);
command_pool_map[pCommandBuffers[index]] = pAllocateInfo->commandPool;
- loader_platform_thread_unlock_mutex(&threadingLock);
}
}
@@ -337,8 +324,7 @@
finishWriteObject(my_data, commandPool);
for (uint32_t index = 0; index < commandBufferCount; index++) {
finishWriteObject(my_data, pCommandBuffers[index], lockCommandPool);
- loader_platform_thread_lock_mutex(&threadingLock);
+ std::lock_guard<std::mutex> lock(global_lock);
command_pool_map.erase(pCommandBuffers[index]);
- loader_platform_thread_unlock_mutex(&threadingLock);
}
}