SeqRingWriter Class Reference
|
Space-ng SDK
|
#include <sol3/core/seq_ring.h>
Public Member Functions | |
| SeqRingWriter (uint32_t slot_type, void *data, size_t data_size, size_t n_slots, size_t slot_size) | |
| uint64_t | write (void const *header_data, size_t header_size, void const *payload_data, size_t payload_size) |
| uint64_t | head () const |
| flatbuffers::span< uint8_t const > | slotSpan (uint64_t seq) const |
| size_t | slotCount () const |
| Number of slots. More... | |
| size_t | slotSize () const |
| Size in bytes of each slot. More... | |
| uint32_t | slotType () const |
Static Public Member Functions | |
| static size_t | minDataSize (size_t n_slots, size_t slot_size) |
Minimum backing data size to hold n_slots of slot_size bytes. More... | |
Detailed Description
Low level slotted ring buffer with sequence lock style writing access. This datastructure allows for single writer, multi-reader with no back pression on writer. It employes a seqlock which allows readers to detect if the data they are reading has been overwritten/torn by the writer.
This datastructure is meant to be initialized in a raw shared memory region, and uses a stable memory interface to this region. Uses a fixed number of slots, each having a fixed slize.
Constructor & Destructor Documentation
◆ SeqRingWriter()
| sol3::core::SeqRingWriter::SeqRingWriter | ( | uint32_t | slot_type, |
| void * | data, | ||
| size_t | data_size, | ||
| size_t | n_slots, | ||
| size_t | slot_size | ||
| ) |
Create a writer over a ring with type, memory range, and shape. This will initialize the datastructure in the memory range. The memory range should not be shared with readers until after this function returns.
Member Function Documentation
◆ head()
| uint64_t sol3::core::SeqRingWriter::head | ( | ) | const |
Return the sequence number associated with the head of the datastructure. A return value of 0 means no valid slot has been written yet.
◆ minDataSize()
|
static |
Minimum backing data size to hold n_slots of slot_size bytes.
◆ slotCount()
| size_t sol3::core::SeqRingWriter::slotCount | ( | ) | const |
Number of slots.
◆ slotSize()
| size_t sol3::core::SeqRingWriter::slotSize | ( | ) | const |
Size in bytes of each slot.
◆ slotSpan()
| flatbuffers::span<uint8_t const> sol3::core::SeqRingWriter::slotSpan | ( | uint64_t | seq | ) | const |
Returns a byte span for a slot that has been written. Sequence value 0 is a sentinel for "invalid / not written" and always returns an empty span. If the requested sequence has not been written, or has been overwritten by a later call to write(), this returns an empty span.
The size will be the size of the written header + payload
◆ slotType()
| uint32_t sol3::core::SeqRingWriter::slotType | ( | ) | const |
The type represented by data in each slot. Typically this is the flatbuffer file_identifier
◆ write()
| uint64_t sol3::core::SeqRingWriter::write | ( | void const * | header_data, |
| size_t | header_size, | ||
| void const * | payload_data, | ||
| size_t | payload_size | ||
| ) |
Write header+payload into the next slot, returning the sequence number of the slot written to.
The documentation for this class was generated from the following file:
- /workspaces/astro/sol3-sdk/cpp/sol3/core/seq_ring.h
Generated by