Pigweed
C/C++ API Reference
|
Classes | |
struct | pw_InlineVarLenEntryQueue_Iterator |
struct | pw_InlineVarLenEntryQueue_Entry |
Macros | |
#define | PW_VARIABLE_LENGTH_ENTRY_QUEUE_DECLARE(variable, max_size_bytes) |
#define | PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) |
Typedefs | |
typedef uint32_t * | pw_InlineVarLenEntryQueue_Handle |
typedef const uint32_t * | pw_InlineVarLenEntryQueue_ConstHandle |
Functions | |
static void | pw_InlineVarLenEntryQueue_Init (uint32_t array[], size_t array_size_uint32) |
static void | pw_InlineVarLenEntryQueue_Clear (pw_InlineVarLenEntryQueue_Handle queue) |
Empties the queue. | |
void | pw_InlineVarLenEntryQueue_Push (pw_InlineVarLenEntryQueue_Handle queue, const void *data, uint32_t data_size_bytes) |
bool | pw_InlineVarLenEntryQueue_TryPush (pw_InlineVarLenEntryQueue_Handle queue, const void *data, const uint32_t data_size_bytes) |
void | pw_InlineVarLenEntryQueue_PushOverwrite (pw_InlineVarLenEntryQueue_Handle queue, const void *data, uint32_t data_size_bytes) |
void | pw_InlineVarLenEntryQueue_Pop (pw_InlineVarLenEntryQueue_Handle queue) |
static pw_InlineVarLenEntryQueue_Iterator | pw_InlineVarLenEntryQueue_Begin (pw_InlineVarLenEntryQueue_ConstHandle queue) |
Returns an iterator to the start of the InlineVarLenEntryQueue . | |
static pw_InlineVarLenEntryQueue_Iterator | pw_InlineVarLenEntryQueue_End (pw_InlineVarLenEntryQueue_ConstHandle queue) |
Returns an iterator that points past the end of the queue. | |
void | pw_InlineVarLenEntryQueue_Iterator_Advance (pw_InlineVarLenEntryQueue_Iterator *iterator) |
static bool | pw_InlineVarLenEntryQueue_Iterator_Equal (const pw_InlineVarLenEntryQueue_Iterator *lhs, const pw_InlineVarLenEntryQueue_Iterator *rhs) |
Compares two iterators for equality. | |
pw_InlineVarLenEntryQueue_Entry | pw_InlineVarLenEntryQueue_GetEntry (const pw_InlineVarLenEntryQueue_Iterator *iterator) |
Dereferences an iterator, loading the entry it points to. | |
uint32_t | pw_InlineVarLenEntryQueue_Entry_Copy (const pw_InlineVarLenEntryQueue_Entry *entry, void *dest, uint32_t count) |
static uint8_t | pw_InlineVarLenEntryQueue_Entry_At (const pw_InlineVarLenEntryQueue_Entry *entry, size_t index) |
uint32_t | pw_InlineVarLenEntryQueue_Size (pw_InlineVarLenEntryQueue_ConstHandle queue) |
static uint32_t | pw_InlineVarLenEntryQueue_MaxSize (pw_InlineVarLenEntryQueue_ConstHandle queue) |
uint32_t | pw_InlineVarLenEntryQueue_SizeBytes (pw_InlineVarLenEntryQueue_ConstHandle queue) |
static uint32_t | pw_InlineVarLenEntryQueue_MaxSizeBytes (pw_InlineVarLenEntryQueue_ConstHandle queue) |
static uint32_t | pw_InlineVarLenEntryQueue_RawStorageSizeBytes (pw_InlineVarLenEntryQueue_ConstHandle queue) |
static bool | pw_InlineVarLenEntryQueue_Empty (pw_InlineVarLenEntryQueue_ConstHandle queue) |
#define PW_VARIABLE_LENGTH_ENTRY_QUEUE_DECLARE | ( | variable, | |
max_size_bytes | |||
) |
Declares and initializes a InlineVarLenEntryQueue
that can hold up to max_size_bytes
bytes. max_size_bytes
is the largest supported size for a single entry; attempting to store larger entries is invalid and will fail an assertion.
variable | variable name for the queue |
max_size_bytes | the capacity of the queue |
#define PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32 (3) |
The size of the InlineVarLenEntryQueue
header, in uint32_t
elements. This header stores the buffer length and head and tail offsets.
The underlying uint32_t
array of a InlineVarLenEntryQueue
must be larger than this size.
typedef uint32_t* pw_InlineVarLenEntryQueue_Handle |
Handle that refers to a InlineVarLenEntryQueue
. In memory, the queue is a uint32_t
array.
|
inlinestatic |
Returns true if the InlineVarLenEntryQueue
is empty, false if it has at least one entry.
|
inlinestatic |
Returns the byte at the specified index in the entry. Asserts if index is out-of-bounds.
uint32_t pw_InlineVarLenEntryQueue_Entry_Copy | ( | const pw_InlineVarLenEntryQueue_Entry * | entry, |
void * | dest, | ||
uint32_t | count | ||
) |
Copies the contents of the entry to the provided buffer. The entry may be split into two regions; this serializes it into one buffer.
entry | The entry whose contents to copy |
dest | The buffer into which to copy the serialized entry |
count | Copy up to this many bytes; must not be larger than the dest buffer, but may be larger than the entry |
|
inlinestatic |
Initializes a InlineVarLenEntryQueue
in place in a uint32_t
array. The array MUST be larger than
embed:rst:inline :c:macro:`PW_VARIABLE_LENGTH_ENTRY_QUEUE_HEADER_SIZE_UINT32`
(3) elements.
void pw_InlineVarLenEntryQueue_Iterator_Advance | ( | pw_InlineVarLenEntryQueue_Iterator * | iterator | ) |
Advances an iterator to point to the next entry in the queue. It is invalid to call Advance
on an iterator equal to the End
iterator.
|
inlinestatic |
Returns the maximum number of entries in the queue. This is only attainable if all entries are empty.
|
inlinestatic |
Returns the the maximum number of bytes that can be stored in the queue. This is largest possible value of size_bytes()
, and the size of the largest single entry that can be stored in this queue. Attempting to store a larger entry is invalid and results in a crash.
void pw_InlineVarLenEntryQueue_Pop | ( | pw_InlineVarLenEntryQueue_Handle | queue | ) |
Removes the first entry from queue.
void pw_InlineVarLenEntryQueue_Push | ( | pw_InlineVarLenEntryQueue_Handle | queue, |
const void * | data, | ||
uint32_t | data_size_bytes | ||
) |
Appends an entry to the end of the queue.
max_size_bytes()
. void pw_InlineVarLenEntryQueue_PushOverwrite | ( | pw_InlineVarLenEntryQueue_Handle | queue, |
const void * | data, | ||
uint32_t | data_size_bytes | ||
) |
Appends an entry to the end of the queue, removing entries with Pop
as necessary to make room. Calling this function drops old entries to make room for new; call try_push()
to drop new entries instead.
max_size_bytes()
.
|
inlinestatic |
Returns the size of the raw underlying InlineVarLenEntryQueue
storage. This size may be used to copy a InlineVarLenEntryQueue
into another 32-bit aligned memory location.
uint32_t pw_InlineVarLenEntryQueue_Size | ( | pw_InlineVarLenEntryQueue_ConstHandle | queue | ) |
Returns the number of variable-length entries in the queue. This is O(n) in the number of entries in the queue.
uint32_t pw_InlineVarLenEntryQueue_SizeBytes | ( | pw_InlineVarLenEntryQueue_ConstHandle | queue | ) |
Returns the combined size in bytes of all entries in the queue, excluding metadata. This is O(n) in the number of entries in the queue.
bool pw_InlineVarLenEntryQueue_TryPush | ( | pw_InlineVarLenEntryQueue_Handle | queue, |
const void * | data, | ||
const uint32_t | data_size_bytes | ||
) |
Appends an entry to the end of the queue, but only if there is sufficient space for it.
max_size_bytes()
.