| 1294 | std::lock_guard<std::mutex> l(mutex_); |
| 1295 | if (capacity_ == kMaxMemory) { |
| 1296 | return 0; |
| 1297 | } |
| 1298 | if (capacity_ < reservationBytes_) { |
| 1299 | // NOTE: the memory reservation could be temporarily larger than its |
| 1300 | // capacity if this memory pool is under memory arbitration processing. |
| 1301 | return 0; |
| 1302 | } |
| 1303 | return capacity_ - reservationBytes_; |
| 1304 | } |
| 1305 | |
| 1306 | void MemoryPoolImpl::setReclaimer(std::unique_ptr<MemoryReclaimer> reclaimer) { |
| 1307 | BOLT_CHECK_NOT_NULL(reclaimer); |
| 1308 | if (parent_ != nullptr) { |
| 1309 | BOLT_CHECK_NOT_NULL( |
| 1310 | parent_->reclaimer(), |
| 1311 | "Child memory pool {} shall only set reclaimer if its parent {} has also set", |
| 1312 | name_, |
| 1313 | parent_->name()); |
no outgoing calls