Thread-safe, but if somebody else can remove the same key while remove() is in progress, then any removed value is not guaranteed to correspond to that key This also applies if the key was not already present but once was. Elements can be removed in an order.
| 64 | // to that key This also applies if the key was not already present but |
| 65 | // once was. Elements can be removed in an order. |
| 66 | TValue* remove(std::uint64_t key) |
| 67 | { |
| 68 | auto idxEntry = get_entry_for_key(key); |
| 69 | if (idxEntry == nullptr) |
| 70 | return nullptr; |
| 71 | TValue* val = nullptr; |
| 72 | while (!idxEntry->value.compare_exchange_weak(val, nullptr, std::memory_order_acquire, std::memory_order_relaxed)) |
| 73 | continue; |
| 74 | return val; |
| 75 | } |
| 76 | |
| 77 | private: |
| 78 | struct IndexEntry |
no test coverage detected