An Annotation
which wraps a LengthDelimitedRingBuffer
of up to Capacity
bytes in length.
More...
#include "client/ring_buffer_annotation.h"
Public Member Functions | |
constexpr | RingBufferAnnotation (Annotation::Type type, const char name[]) |
Constructs a RingBufferAnnotation . | |
RingBufferAnnotation (const RingBufferAnnotation &)=delete | |
RingBufferAnnotation & | operator= (const RingBufferAnnotation &)=delete |
RingBufferAnnotation (RingBufferAnnotation &&)=default | |
RingBufferAnnotation & | operator= (RingBufferAnnotation &&)=default |
bool | Push (const void *const buffer, RingBufferAnnotationCapacity buffer_length) |
Pushes data onto this annotation's ring buffer. | |
void | ResetForTesting () |
Reset the annotation (e.g., for testing). This method is not thread-safe. | |
Public Member Functions inherited from crashpad::Annotation | |
constexpr | Annotation (Type type, const char name[], void *value_ptr) |
Constructs a new annotation. | |
Annotation (const Annotation &)=delete | |
Annotation & | operator= (const Annotation &)=delete |
void | SetSize (ValueSizeType size) |
Specifies the number of bytes in value_ptr_ to include when generating a crash report. | |
void | Clear () |
Marks the annotation as cleared, indicating the value_ptr_ should not be included in a crash report. | |
bool | is_set () const |
Tests whether the annotation has been set. | |
Type | type () const |
ValueSizeType | size () const |
const char * | name () const |
const void * | value () const |
ConcurrentAccessGuardMode | concurrent_access_guard_mode () const |
std::optional< ScopedSpinGuard > | TryCreateScopedSpinGuard (uint64_t timeout_ns) |
If this Annotation guards concurrent access using ScopedSpinGuard, tries to obtain the spin guard and returns the result. | |
Additional Inherited Members | |
Public Types inherited from crashpad::Annotation | |
enum class | Type : uint16_t |
The type of data stored in the annotation. More... | |
enum class | ConcurrentAccessGuardMode : bool |
Mode used to guard concurrent reads from writes. More... | |
using | ValueSizeType = uint32_t |
The type used for SetSize(). | |
Static Public Member Functions inherited from crashpad::Annotation | |
static constexpr Type | UserDefinedType (uint16_t value) |
Creates a user-defined Annotation::Type. | |
Static Public Attributes inherited from crashpad::Annotation | |
static constexpr size_t | kNameMaxLength = 256 |
The maximum length of an annotation’s name, in bytes. Matches the behavior of Breakpad's SimpleStringDictionary. | |
static constexpr size_t | kValueMaxSize = 5 * 4096 |
The maximum size of an annotation’s value, in bytes. | |
Protected Member Functions inherited from crashpad::Annotation | |
constexpr | Annotation (Type type, const char name[], void *value_ptr, ConcurrentAccessGuardMode concurrent_access_guard_mode) |
Constructs a new annotation. | |
std::atomic< Annotation * > & | link_node () |
Annotation * | GetLinkNode (std::memory_order order=std::memory_order_seq_cst) |
const Annotation * | GetLinkNode (std::memory_order order=std::memory_order_seq_cst) const |
An Annotation
which wraps a LengthDelimitedRingBuffer
of up to Capacity
bytes in length.
Supports writing variable-length data via Push()
. When the ring buffer is full, it will drop old data items in FIFO order until enough space is available for the write.
Supports guarding concurrent reads from writes via ScopedSpinGuard
, so writing to this object is thread-safe.
Clients which read this Annotation
's memory can optionally invoke TryCreateScopedSpinGuard()
on this object to ensure any pending write finishes before the memory is read.
Each item in this ring buffer is delimited by its length encoded in little-endian Base 128 varint encoding.
RingBufferAnnotation
uses varint-encoded delimiters to enable zero-copy deserialization of the ringbuffer's contents when storing protobufs inside the ringbuffer, e.g. via google::protobuf::util::ParseDelimitedFromZeroCopyStream()
or similar.
To deserialize the items stored in this annotation, use LengthDelimitedRingBufferReader
.
|
inlineconstexpr |
Constructs a RingBufferAnnotation
.
[in] | type | A unique identifier for the type of data in the ring buffer. |
[in] | name | The name of the annotation. |
|
inline |
Pushes data onto this annotation's ring buffer.
If the ring buffer does not have enough space to store buffer_length
bytes of data, old data items are dropped in FIFO order until enough space is available to store the new data.