Skip to content

Commit

Permalink
Fix the crash caused by pendingPurgeableResources potentially perform…
Browse files Browse the repository at this point in the history
…ing swap and push_back operations simultaneously. (#60)
  • Loading branch information
Hparty authored Nov 30, 2023
1 parent 079c2e2 commit f727c44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gpu/ResourceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void ResourceCache::detachFromCurrentThread() {
// strongReferences 保护已经开启,这时候不会再有任何外部的 Resource 会触发
// NotifyReferenceReachedZero()。
std::vector<Resource*> pendingResources = {};
std::swap(pendingResources, pendingPurgeableResources);
{
std::lock_guard lockGuard(removeLocker);
std::swap(pendingResources, pendingPurgeableResources);
}
for (auto& resource : pendingResources) {
processUnreferencedResource(resource);
}
Expand Down

0 comments on commit f727c44

Please sign in to comment.