Assert that compacting flag is not already set for buffer that
is candiate for compaction.
Use markCompacting() to mark buffer being compacted.
@@ -480,10 +480,7 @@ DataStoreBase::startCompactWorstBuffer(uint32_t typeId)
assert(typeHandler->get_active_buffers_count() >= 1u);
if (typeHandler->get_active_buffers_count() == 1u) {
// Single active buffer for type, no need for scan
- _states[buffer_id].setCompacting();
- _states[buffer_id].disableElemHoldList();
- disableFreeList(buffer_id);
- switch_primary_buffer(typeId, 0u);
+ markCompacting(buffer_id);
return buffer_id;
}
// Multiple active buffers for type, must perform full scan
@@ -500,6 +497,7 @@ DataStoreBase::startCompactWorstBuffer(uint32_t initWorstBufferId, BufferStateAc
for (uint32_t bufferId = 0; bufferId < _numBuffers; ++bufferId) {
const auto &state = getBufferState(bufferId);
if (filterFunc(state)) {
+ assert(!state.getCompacting());
size_t deadElems = state.getDeadElems() - state.getTypeHandler()->getReservedElements(bufferId);
if (deadElems > worstDeadElems) {
worstBufferId = bufferId;
@@ -520,6 +518,7 @@ DataStoreBase::markCompacting(uint32_t bufferId)
if ((bufferId == buffer_id) || primary_buffer_too_dead(getBufferState(buffer_id))) {
switch_primary_buffer(typeId, 0u);
}
+ assert(!state.getCompacting());
state.setCompacting();
state.disableElemHoldList();
state.setFreeListList(nullptr);
