Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
cuckoocache.h
Go to the documentation of this file.
343 depth_limit = static_cast<uint8_t>(std::log2(static_cast<float>(std::max((uint32_t)2, new_size))));
constexpr auto log2(T x) -> std::enable_if_t<!std::is_same< decltype(clz_(x)), not_supported_t >::value, T >
Definition: util.hpp:100
bool bit_is_set(uint32_t s) const
bit_is_set queries the table for discardability at s
Definition: cuckoocache.h:113
void please_keep(uint32_t n) const
please_keep marks the element at index n as an entry that should be kept.
Definition: cuckoocache.h:275
std::unique_ptr< std::atomic< uint8_t >[]> mem
Definition: cuckoocache.h:44
bit_packed_atomic_flags(uint32_t size)
bit_packed_atomic_flags constructor creates memory to sufficiently keep track of garbage collection i...
Definition: cuckoocache.h:61
cache implements a cache with properties similar to a cuckoo-set
Definition: cuckoocache.h:160
bool contains(const Element &e, const bool erase) const
Definition: cuckoocache.h:467
uint32_t epoch_size
epoch_size is set to be the number of elements supposed to be in a epoch.
Definition: cuckoocache.h:194
std::vector< bool > epoch_flags
epoch_flags tracks how recently an element was inserted into the cache.
Definition: cuckoocache.h:177
const Hash hash_function
hash_function is a const instance of the hash function.
Definition: cuckoocache.h:204
bit_packed_atomic_flags implements a container for garbage collection flags that is only thread unsaf...
Definition: cuckoocache.h:42
cache()
You must always construct a cache with some elements via a subsequent call to setup or setup_bytes...
Definition: cuckoocache.h:327
uint8_t depth_limit
depth_limit determines how many elements insert should try to replace.
Definition: cuckoocache.h:198
uint32_t epoch_heuristic_counter
epoch_heuristic_counter is used to determine when an epoch might be aged & an expensive scan should b...
Definition: cuckoocache.h:184
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
Definition: hash.h:84
void insert(Element e)
insert loops at most depth_limit times trying to insert a hash at various locations in the table via ...
Definition: cuckoocache.h:392
std::array< uint32_t, 8 > compute_hashes(const Element &e) const
compute_hashes is convenience for not having to write out this expression everywhere we use the hash ...
Definition: cuckoocache.h:243
uint32_t setup_bytes(size_t bytes)
setup_bytes is a convenience function which accounts for internal memory usage when deciding how many...
Definition: cuckoocache.h:367
namespace CuckooCache provides high performance cache primitives
Definition: cuckoocache.h:27
void epoch_check()
epoch_check handles the changing of epochs for elements stored in the cache.
Definition: cuckoocache.h:289
void allow_erase(uint32_t n) const
allow_erase marks the element at index n as discardable.
Definition: cuckoocache.h:266
bit_packed_atomic_flags collection_flags
The bit_packed_atomic_flags array is marked mutable because we want garbage collection to be allowed ...
Definition: cuckoocache.h:171
uint32_t setup(uint32_t new_size)
setup initializes the container to store no more than new_size elements.
Definition: cuckoocache.h:340
void bit_unset(uint32_t s)
bit_unset marks an entry as something that should not be overwritten
Definition: cuckoocache.h:103
void setup(uint32_t b)
setup marks all entries and ensures that bit_packed_atomic_flags can store at least size entries ...
Definition: cuckoocache.h:79
bit_packed_atomic_flags()=delete
No default constructor as there must be some size.