1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Remove unused lf_hashmap

There are better ways to implement this.
This commit is contained in:
Nekotekina 2020-02-28 09:56:34 +03:00
parent 30f7c81cc5
commit bf4bdf73b7

View File

@ -98,49 +98,6 @@ public:
} }
}; };
//! Simple lock-free map. Based on lf_array<>. All elements are accessible, implicitly initialized.
template<typename K, typename T, typename Hash = value_hash<K>, std::size_t Size = 256>
class lf_hashmap
{
struct pair_t
{
// Default-constructed key means "no key"
atomic_t<K> key{};
T value{};
};
//
lf_array<pair_t, Size> m_data{};
// Value for default-constructed key
T m_default_key_data{};
public:
constexpr lf_hashmap() = default;
// Access element (added implicitly)
T& operator [](const K& key)
{
if (key == K{}) [[unlikely]]
{
return m_default_key_data;
}
// Calculate hash and array position
for (std::size_t pos = Hash{}(key) % Size;; pos += Size)
{
// Access the array
auto& pair = m_data[pos];
// Check the key value (optimistic)
if (pair.key == key || pair.key.compare_and_swap_test(K{}, key)) [[likely]]
{
return pair.value;
}
}
}
};
// Helper type, linked list element // Helper type, linked list element
template <typename T> template <typename T>
class lf_queue_item final class lf_queue_item final