Open qqiangwu opened 7 months ago
ColumnFamilyData* DBImpl::PickCompactionFromQueue(
std::unique_ptr<TaskLimiterToken>* token, LogBuffer* log_buffer) {
assert(!compaction_queue_.empty());
assert(*token == nullptr);
autovector<ColumnFamilyData*> throttled_candidates;
ColumnFamilyData* cfd = nullptr;
while (!compaction_queue_.empty()) {
// pset(compaction_queue_) = {*this}
// pset(compaction_queue_.begin()) = {*this}
// pset(*compaction_queue_.begin()) = {**this}
auto first_cfd = *compaction_queue_.begin();
compaction_queue_.pop_front();
assert(first_cfd->queued_for_compaction());
// RequestCompactionToken is a non-const member function so `first_cfd` is invalidated
if (!RequestCompactionToken(first_cfd, false, token, log_buffer)) {
// pset(first_cfd) = {invalid}
throttled_candidates.push_back(first_cfd);
continue;
}
cfd = first_cfd;
cfd->set_queued_for_compaction(false);
break;
}
// Add throttled compaction candidates back to queue in the original order.
for (auto iter = throttled_candidates.rbegin();
iter != throttled_candidates.rend(); ++iter) {
compaction_queue_.push_front(*iter);
}
return cfd;
}
std::vector<int>
is an owner ofint
std::vector<int*>
is an owner ofint*
not, but according to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2816r0.pdf , it should be viewed as pointers