Fabcoin Core
0.16.2
P2P Digital Currency
|
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 |
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.
|
delete |
No default constructor as there must be some size.
|
inline |
bit_packed_atomic_flags constructor creates memory to sufficiently keep track of garbage collection information for size entries.
size | the number of elements to allocate space for |
Definition at line 61 of file cuckoocache.h.
|
inline |
bit_is_set queries the table for discardability at s
s | the index of the entry to read. |
Definition at line 113 of file cuckoocache.h.
|
inline |
bit_set sets an entry as discardable.
s | the index of the entry to bit_set. |
Definition at line 92 of file cuckoocache.h.
|
inline |
bit_unset marks an entry as something that should not be overwritten
s | the index of the entry to bit_unset. |
Definition at line 103 of file cuckoocache.h.
|
inline |
setup marks all entries and ensures that bit_packed_atomic_flags can store at least size entries
b | the number of elements to allocate space for |
Definition at line 79 of file cuckoocache.h.
|
private |
Definition at line 44 of file cuckoocache.h.