From 99e5cadc3c6041dec98f17bc8661a764f4cae2d6 Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Fri, 6 Jan 2023 17:18:02 -0800 Subject: [PATCH] Add mutex when acquiring allocation. --- src/gpgmm/common/MemoryAllocator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gpgmm/common/MemoryAllocator.cpp b/src/gpgmm/common/MemoryAllocator.cpp index 9f1703009..b0afaabbe 100644 --- a/src/gpgmm/common/MemoryAllocator.cpp +++ b/src/gpgmm/common/MemoryAllocator.cpp @@ -27,10 +27,12 @@ namespace gpgmm { } void operator()() override { + std::lock_guard lock(mAllocationMutex); mAllocation = mAllocator->TryAllocateMemory(mRequest); } std::unique_ptr AcquireAllocation() { + std::lock_guard lock(mAllocationMutex); return std::move(mAllocation); } @@ -38,6 +40,7 @@ namespace gpgmm { MemoryAllocator* const mAllocator; const MemoryAllocationRequest mRequest; + std::mutex mAllocationMutex; std::unique_ptr mAllocation; };