| 534 | } |
| 535 | |
| 536 | void MemoryPool::completeSlabRelease(const SlabReleaseContext& context) { |
| 537 | if (context.isReleased()) { |
| 538 | // the slab release is already completed. |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | if (context.getReceiverClassId() != Slab::kInvalidClassId && |
| 543 | context.getMode() != SlabReleaseMode::kRebalance) { |
| 544 | throw std::invalid_argument(fmt::format( |
| 545 | "A valid receiver {} is specified but the rebalancing mode is " |
| 546 | "not SlabReleaseMode::kRebalance", |
| 547 | context.getReceiverClassId())); |
| 548 | } |
| 549 | |
| 550 | auto slab = context.getSlab(); |
| 551 | auto mode = context.getMode(); |
| 552 | auto classId = context.getClassId(); |
| 553 | auto zeroOnRelease = context.shouldZeroOnRelease(); |
| 554 | auto& allocClass = getAllocationClassFor(classId); |
| 555 | |
| 556 | // complete the slab release process. |
| 557 | allocClass.completeSlabRelease(context); |
| 558 | |
| 559 | XDCHECK_EQ(slabAllocator_.getSlabHeader(slab)->getPoolId(), getId()); |
| 560 | XDCHECK_EQ(slabAllocator_.getSlabHeader(slab)->getClassId(), |
| 561 | Slab::kInvalidClassId); |
| 562 | XDCHECK_EQ(slabAllocator_.getSlabHeader(slab)->getAllocSize(), 0u); |
| 563 | |
| 564 | releaseSlab(mode, slab, zeroOnRelease, context.getReceiverClassId()); |
| 565 | } |
| 566 | |
| 567 | MPStats MemoryPool::getStats() const { |
| 568 | LockHolder l(lock_); |