/// Gives up ownership previously granted by alloc()
void recycleIndex(uint32_t idx) {
assert(isAllocated(idx));
- Traits::onRecycle(&slot(idx).elem);
localPush(localHead(), idx);
}
Slot& s = slot(idx);
TaggedPtr h = head.load(std::memory_order_acquire);
while (true) {
- s.localNext.store(h.idx, std::memory_order_relaxed);
+ s.localNext.store(h.idx, std::memory_order_release);
+ Traits::onRecycle(&slot(idx).elem);
if (h.size() == LocalListLimit) {
// push will overflow local list, steal it instead
elem = nullptr;
EXPECT_CALL(traits, onRecycle(_)).WillOnce(Invoke([&](std::string* s) {
- EXPECT_TRUE(pool.isAllocated(pool.locateElem(s)));
+ EXPECT_FALSE(pool.isAllocated(pool.locateElem(s)));
elem = s;
}));
pool.recycleIndex(pool.locateElem(ptr));