Public Member Functions | Private Attributes | List of all members
grpc_event_engine::experimental::SliceBuffer Class Reference

#include <slice_buffer.h>

Public Member Functions

void Append (Slice slice)
 
size_t AppendIndexed (Slice slice)
 
grpc_slice_bufferc_slice_buffer ()
 Return a pointer to the back raw grpc_slice_buffer. More...
 
void Clear ()
 Removes and unrefs all slices in the SliceBuffer. More...
 
size_t Count ()
 Returns the number of slices held by the SliceBuffer. More...
 
size_t Length ()
 The total number of bytes held by the SliceBuffer. More...
 
void MoveFirstNBytesIntoBuffer (size_t n, void *dst)
 Move the first n bytes of the SliceBuffer into a memory pointed to by dst. More...
 
SliceBufferoperator= (const SliceBuffer &)=delete
 
SliceBufferoperator= (SliceBuffer &&other) noexcept
 
void Prepend (Slice slice)
 Prepends the slice to the the front of the SliceBuffer. More...
 
Slice RefSlice (size_t index)
 
void RemoveLastNBytes (size_t n)
 Removes/deletes the last n bytes in the SliceBuffer. More...
 
 SliceBuffer ()
 
 SliceBuffer (const SliceBuffer &other)=delete
 
 SliceBuffer (SliceBuffer &&other) noexcept
 
Slice TakeFirst ()
 Removes the first slice in the SliceBuffer and returns it. More...
 
 ~SliceBuffer ()
 

Private Attributes

grpc_slice_buffer slice_buffer_
 The backing raw slice buffer. More...
 

Detailed Description

A Wrapper around grpc_slice_buffer pointer.

A slice buffer holds the memory for a collection of slices. The SliceBuffer object itself is meant to only hide the C-style API, and won't hold the data itself. In terms of lifespan, the grpc_slice_buffer ought to be kept somewhere inside the caller's objects, like a transport or an endpoint.

This lifespan rule is likely to change in the future, as we may collapse the grpc_slice_buffer structure straight into this class.

The SliceBuffer API is basically a replica of the grpc_slice_buffer's, and its documentation will move here once we remove the C structure, which should happen before the Event Engine's API is no longer an experimental API.

Definition at line 51 of file include/grpc/event_engine/slice_buffer.h.

Constructor & Destructor Documentation

◆ SliceBuffer() [1/3]

grpc_event_engine::experimental::SliceBuffer::SliceBuffer ( )
inlineexplicit

Definition at line 53 of file include/grpc/event_engine/slice_buffer.h.

◆ SliceBuffer() [2/3]

grpc_event_engine::experimental::SliceBuffer::SliceBuffer ( const SliceBuffer other)
delete

◆ SliceBuffer() [3/3]

grpc_event_engine::experimental::SliceBuffer::SliceBuffer ( SliceBuffer &&  other)
inlinenoexcept

Definition at line 55 of file include/grpc/event_engine/slice_buffer.h.

◆ ~SliceBuffer()

grpc_event_engine::experimental::SliceBuffer::~SliceBuffer ( )
inline

Upon destruction, the underlying raw slice buffer is cleaned out and all slices are unreffed.

Definition at line 62 of file include/grpc/event_engine/slice_buffer.h.

Member Function Documentation

◆ Append()

void grpc_event_engine::experimental::SliceBuffer::Append ( Slice  slice)

Appends a new slice into the SliceBuffer and makes an attempt to merge this slice with the last slice in the SliceBuffer.

Definition at line 29 of file event_engine/slice_buffer.cc.

◆ AppendIndexed()

size_t grpc_event_engine::experimental::SliceBuffer::AppendIndexed ( Slice  slice)

Adds a new slice into the SliceBuffer at the next available index. Returns the index at which the new slice is added.

Definition at line 33 of file event_engine/slice_buffer.cc.

◆ c_slice_buffer()

grpc_slice_buffer* grpc_event_engine::experimental::SliceBuffer::c_slice_buffer ( )
inline

Return a pointer to the back raw grpc_slice_buffer.

Definition at line 108 of file include/grpc/event_engine/slice_buffer.h.

◆ Clear()

void grpc_event_engine::experimental::SliceBuffer::Clear ( )
inline

Removes and unrefs all slices in the SliceBuffer.

Definition at line 92 of file include/grpc/event_engine/slice_buffer.h.

◆ Count()

size_t grpc_event_engine::experimental::SliceBuffer::Count ( )
inline

Returns the number of slices held by the SliceBuffer.

Definition at line 79 of file include/grpc/event_engine/slice_buffer.h.

◆ Length()

size_t grpc_event_engine::experimental::SliceBuffer::Length ( )
inline

The total number of bytes held by the SliceBuffer.

Definition at line 105 of file include/grpc/event_engine/slice_buffer.h.

◆ MoveFirstNBytesIntoBuffer()

void grpc_event_engine::experimental::SliceBuffer::MoveFirstNBytesIntoBuffer ( size_t  n,
void *  dst 
)
inline

Move the first n bytes of the SliceBuffer into a memory pointed to by dst.

Definition at line 87 of file include/grpc/event_engine/slice_buffer.h.

◆ operator=() [1/2]

SliceBuffer& grpc_event_engine::experimental::SliceBuffer::operator= ( const SliceBuffer )
delete

◆ operator=() [2/2]

SliceBuffer& grpc_event_engine::experimental::SliceBuffer::operator= ( SliceBuffer &&  other)
inlinenoexcept

Definition at line 65 of file include/grpc/event_engine/slice_buffer.h.

◆ Prepend()

void grpc_event_engine::experimental::SliceBuffer::Prepend ( Slice  slice)

Prepends the slice to the the front of the SliceBuffer.

Definition at line 41 of file event_engine/slice_buffer.cc.

◆ RefSlice()

Slice grpc_event_engine::experimental::SliceBuffer::RefSlice ( size_t  index)

Increased the ref-count of slice at the specified index and returns the associated slice.

Definition at line 45 of file event_engine/slice_buffer.cc.

◆ RemoveLastNBytes()

void grpc_event_engine::experimental::SliceBuffer::RemoveLastNBytes ( size_t  n)
inline

Removes/deletes the last n bytes in the SliceBuffer.

Definition at line 82 of file include/grpc/event_engine/slice_buffer.h.

◆ TakeFirst()

Slice grpc_event_engine::experimental::SliceBuffer::TakeFirst ( )

Removes the first slice in the SliceBuffer and returns it.

Definition at line 37 of file event_engine/slice_buffer.cc.

Member Data Documentation

◆ slice_buffer_

grpc_slice_buffer grpc_event_engine::experimental::SliceBuffer::slice_buffer_
private

The backing raw slice buffer.

Definition at line 112 of file include/grpc/event_engine/slice_buffer.h.


The documentation for this class was generated from the following files:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:40