Bitcoin ABC 0.26.3
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. | |
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. | |
void | setup (uint32_t b) |
setup marks all entries and ensures that bit_packed_atomic_flags can store at least b entries. | |
void | bit_set (uint32_t s) |
bit_set sets an entry as discardable. | |
void | bit_unset (uint32_t s) |
bit_unset marks an entry as something that should not be overwritten. | |
bool | bit_is_set (uint32_t s) const |
bit_is_set queries the table for discardability at s . | |
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 47 of file cuckoocache.h.
|
delete |
No default constructor, as there must be some size.
|
inlineexplicit |
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 65 of file cuckoocache.h.
bit_is_set queries the table for discardability at s
.
s | the index of the entry to read |
s
was set, false otherwise Definition at line 118 of file cuckoocache.h.
bit_set sets an entry as discardable.
s | the index of the entry to bit_set |
Definition at line 96 of file cuckoocache.h.
bit_unset marks an entry as something that should not be overwritten.
s | the index of the entry to bit_unset |
Definition at line 107 of file cuckoocache.h.
setup marks all entries and ensures that bit_packed_atomic_flags can store at least b
entries.
b | the number of elements to allocate space for |
Definition at line 84 of file cuckoocache.h.
|
private |
Definition at line 48 of file cuckoocache.h.