Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

CuckooCache::bit_packed_atomic_flags Class Reference

bit_packed_atomic_flags implements a container for garbage collection flags that is only thread unsafe on calls to setup. More...

#include <cuckoocache.h>

Public Member Functions

 bit_packed_atomic_flags ()=delete
 No default constructor as there must be some size. More...
 
 bit_packed_atomic_flags (uint32_t size)
 bit_packed_atomic_flags constructor creates memory to sufficiently keep track of garbage collection information for size entries. More...
 
void setup (uint32_t b)
 setup marks all entries and ensures that bit_packed_atomic_flags can store at least size entries More...
 
void bit_set (uint32_t s)
 bit_set sets an entry as discardable. More...
 
void bit_unset (uint32_t s)
 bit_unset marks an entry as something that should not be overwritten More...
 
bool bit_is_set (uint32_t s) const
 bit_is_set queries the table for discardability at s More...
 

Private Attributes

std::unique_ptr< std::atomic< uint8_t >[]> mem
 

Detailed Description

bit_packed_atomic_flags implements a container for garbage collection flags that is only thread unsafe on calls to setup.

This class bit-packs collection flags for memory efficiency.

All operations are std::memory_order_relaxed so external mechanisms must ensure that writes and reads are properly synchronized.

On setup(n), all bits up to n are marked as collected.

Under the hood, because it is an 8-bit type, it makes sense to use a multiple of 8 for setup, but it will be safe if that is not the case as well.

Definition at line 42 of file cuckoocache.h.

Constructor & Destructor Documentation

◆ bit_packed_atomic_flags() [1/2]

CuckooCache::bit_packed_atomic_flags::bit_packed_atomic_flags ( )
delete

No default constructor as there must be some size.

◆ bit_packed_atomic_flags() [2/2]

CuckooCache::bit_packed_atomic_flags::bit_packed_atomic_flags ( uint32_t  size)
inlineexplicit

bit_packed_atomic_flags constructor creates memory to sufficiently keep track of garbage collection information for size entries.

Parameters
sizethe number of elements to allocate space for
Postcondition
bit_set, bit_unset, and bit_is_set function properly forall x. x < size
All calls to bit_is_set (without subsequent bit_unset) will return true.

Definition at line 61 of file cuckoocache.h.

References mem.

Member Function Documentation

◆ bit_is_set()

bool CuckooCache::bit_packed_atomic_flags::bit_is_set ( uint32_t  s) const
inline

bit_is_set queries the table for discardability at s

Parameters
sthe index of the entry to read.
Returns
if the bit at index s was set.

Definition at line 113 of file cuckoocache.h.

References mem.

Referenced by CuckooCache::cache< Element, Hash >::epoch_check(), and CuckooCache::cache< Element, Hash >::insert().

◆ bit_set()

void CuckooCache::bit_packed_atomic_flags::bit_set ( uint32_t  s)
inline

bit_set sets an entry as discardable.

Parameters
sthe index of the entry to bit_set.
Postcondition
immediately subsequent call (assuming proper external memory ordering) to bit_is_set(s) == true.

Definition at line 92 of file cuckoocache.h.

References mem.

Referenced by CuckooCache::cache< Element, Hash >::allow_erase().

◆ bit_unset()

void CuckooCache::bit_packed_atomic_flags::bit_unset ( uint32_t  s)
inline

bit_unset marks an entry as something that should not be overwritten

Parameters
sthe index of the entry to bit_unset.
Postcondition
immediately subsequent call (assuming proper external memory ordering) to bit_is_set(s) == false.

Definition at line 103 of file cuckoocache.h.

References mem.

Referenced by CuckooCache::cache< Element, Hash >::please_keep().

◆ setup()

void CuckooCache::bit_packed_atomic_flags::setup ( uint32_t  b)
inline

setup marks all entries and ensures that bit_packed_atomic_flags can store at least size entries

Parameters
bthe number of elements to allocate space for
Postcondition
bit_set, bit_unset, and bit_is_set function properly forall x. x < b
All calls to bit_is_set (without subsequent bit_unset) will return true.

Definition at line 79 of file cuckoocache.h.

References mem.

Referenced by CuckooCache::cache< Element, Hash >::setup().

Member Data Documentation

◆ mem

std::unique_ptr<std::atomic<uint8_t>[]> CuckooCache::bit_packed_atomic_flags::mem
private

Definition at line 44 of file cuckoocache.h.

Referenced by bit_is_set(), bit_packed_atomic_flags(), bit_set(), bit_unset(), and setup().


The documentation for this class was generated from the following file:
Released under the MIT license