void Carrier::unsafe_remove (const Ob ob) { UniqueLock lock(m_mutex); POMAGMA_ASSERT2(m_support.contains(ob), "double removal: " << ob); Ob rep = ob; while (not m_reps[rep].compare_exchange_strong(rep, rep)) {} POMAGMA_ASSERT2(rep, "double removal: " << ob); if (rep == ob) { for (Ob other = ob + 1, end = item_dim(); other <= end; ++other) { POMAGMA_ASSERT2(m_reps[other].load() != ob, "removed rep " << ob << " before dep " << other); } --m_rep_count; } else { for (Ob other = ob + 1, end = item_dim(); other <= end; ++other) { Ob expected = ob; m_reps[other].compare_exchange_strong(expected, rep); } } m_support.remove(ob); m_reps[ob].store(0); --m_item_count; POMAGMA_DEBUG1(m_item_count.load() << " obs after remove()"); }
Ob Carrier::merge (Ob dep, Ob rep) const { SharedLock lock(m_mutex); POMAGMA_ASSERT2(dep > rep, "out of order merge: " << dep << "," << rep); POMAGMA_ASSERT2(m_support.contains(dep), "bad merge dep " << dep); POMAGMA_ASSERT2(m_support.contains(rep), "bad merge rep " << rep); while (not m_reps[dep].compare_exchange_weak( dep, rep, std::memory_order_acq_rel, std::memory_order_acquire)) { rep = m_reps[rep].load(std::memory_order_acquire); if (dep == rep) return rep; if (dep < rep) std::swap(dep, rep); } if (m_merge_callback) { m_merge_callback(dep); } --m_rep_count; return rep; }
inline void dense_bin_fun::remove (oid_t lhs, oid_t rhs) { oid_t & old_val = value(lhs, rhs); POMAGMA_ASSERT2(old_val, "double removal: " << lhs << "," << rhs); old_val = 0; bool_ref Lx_bit = m_lines.Lx(lhs, rhs); POMAGMA_ASSERT4(Lx_bit, "double removal: " << lhs << "," << rhs); Lx_bit.zero(); bool_ref Rx_bit = m_lines.Rx(lhs, rhs); POMAGMA_ASSERT4(Rx_bit, "double removal: " << lhs << "," << rhs); Rx_bit.zero(); }
inline void dense_bin_fun::insert (oid_t lhs, oid_t rhs, oid_t val) { oid_t & old_val = value(lhs, rhs); POMAGMA_ASSERT2(not old_val, "double insertion: " << lhs << "," << rhs); old_val = val; bool_ref Lx_bit = m_lines.Lx(lhs, rhs); POMAGMA_ASSERT4(not Lx_bit, "double insertion: " << lhs << "," << rhs); Lx_bit.one(); bool_ref Rx_bit = m_lines.Rx(lhs, rhs); POMAGMA_ASSERT4(not Rx_bit, "double insertion: " << lhs << "," << rhs); Rx_bit.one(); }