| 656 | } |
| 657 | |
| 658 | void DBImpl::MaybeScheduleCompaction() { |
| 659 | mutex_.AssertHeld(); |
| 660 | if (background_compaction_scheduled_) { |
| 661 | // Already scheduled |
| 662 | } else if (shutting_down_.load(std::memory_order_acquire)) { |
| 663 | // DB is being deleted; no more background compactions |
| 664 | } else if (!bg_error_.ok()) { |
| 665 | // Already got an error; no more changes |
| 666 | } else if (imm_ == nullptr && manual_compaction_ == nullptr && |
| 667 | !versions_->NeedsCompaction()) { |
| 668 | // No work to be done |
| 669 | } else { |
| 670 | background_compaction_scheduled_ = true; |
| 671 | env_->Schedule(&DBImpl::BGWork, this); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | void DBImpl::BGWork(void* db) { |
| 676 | reinterpret_cast<DBImpl*>(db)->BackgroundCall(); |
no test coverage detected