Skip to content

Commit

Permalink
migrate from nested-name WriteHolder (facebookincubator#8243)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebookincubator#8243

Migrate from nested-name `{mutex}::WriteHolder` to `std::unique_lock`.

Reviewed By: Gownta

Differential Revision: D52517295

fbshipit-source-id: 6657fbe25f8bb1fa167de3efec807f0d8ec6dfb7
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jan 12, 2024
1 parent 72c7951 commit a0146d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions velox/common/memory/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ std::shared_ptr<MemoryPool> MemoryManager::addRootPool(
options.debugEnabled = debugEnabled_;
options.coreOnAllocationFailureEnabled = coreOnAllocationFailureEnabled_;

folly::SharedMutex::WriteHolder guard{mutex_};
std::unique_lock guard{mutex_};
if (pools_.find(poolName) != pools_.end()) {
VELOX_FAIL("Duplicate root pool name found: {}", poolName);
}
Expand Down Expand Up @@ -231,7 +231,7 @@ uint64_t MemoryManager::shrinkPools(uint64_t targetBytes) {

void MemoryManager::dropPool(MemoryPool* pool) {
VELOX_CHECK_NOT_NULL(pool);
folly::SharedMutex::WriteHolder guard{mutex_};
std::unique_lock guard{mutex_};
auto it = pools_.find(pool->name());
if (it == pools_.end()) {
VELOX_FAIL("The dropped memory pool {} not found", pool->name());
Expand Down
6 changes: 3 additions & 3 deletions velox/common/memory/MemoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ std::shared_ptr<MemoryPool> MemoryPool::addLeafChild(
std::unique_ptr<MemoryReclaimer> reclaimer) {
CHECK_POOL_MANAGEMENT_OP(addLeafChild);

folly::SharedMutex::WriteHolder guard{poolMutex_};
std::unique_lock guard{poolMutex_};
VELOX_CHECK_EQ(
children_.count(name),
0,
Expand All @@ -329,7 +329,7 @@ std::shared_ptr<MemoryPool> MemoryPool::addAggregateChild(
std::unique_ptr<MemoryReclaimer> reclaimer) {
CHECK_POOL_MANAGEMENT_OP(addAggregateChild);

folly::SharedMutex::WriteHolder guard{poolMutex_};
std::unique_lock guard{poolMutex_};
VELOX_CHECK_EQ(
children_.count(name),
0,
Expand All @@ -348,7 +348,7 @@ std::shared_ptr<MemoryPool> MemoryPool::addAggregateChild(

void MemoryPool::dropChild(const MemoryPool* child) {
CHECK_POOL_MANAGEMENT_OP(dropChild);
folly::SharedMutex::WriteHolder guard{poolMutex_};
std::unique_lock guard{poolMutex_};
const auto ret = children_.erase(child->name());
VELOX_CHECK_EQ(
ret,
Expand Down

0 comments on commit a0146d7

Please sign in to comment.