An IOBufQueue encapsulates a chain of IOBufs and provides convenience functions to append data to the back of the chain and remove data from the front.

Synopsis

Declared in <folly/io/IOBufQueue.h>

class IOBufQueue;

Description

You may also prepend data into the headroom of the first buffer in the chain, if any.

Types

Name

Description

Options

Configuration options for an IOBufQueue.

WritableRangeCache

WritableRangeCache represents a cache of current writable tail and provides cheap and simple interface to append to it that avoids paying the cost of preallocate/postallocate pair (i.e. indirections and checks).

Member Functions

Name

Description

IOBufQueue [constructor]

Constructors

~IOBufQueue [destructor]

Destructor.

operator=

Move assignment operator.

allocate

Obtain a writable block of n contiguous bytes, allocating more space if necessary, and mark it as used. methodset Allocation

append

append overloads

appendToString

Append the queue to a std::string. methodset Utility

chainLength

Get cached chain length. methodset Capacity

clearAndTryReuseLargestBuffer

Clear the queue, but try to clear and keep the largest buffer for reuse when possible. methodset Allocation

empty

Returns true iff the IOBuf chain length is 0. methodset Capacity

front

Access the front IOBuf. methodset Access

gather

Calls IOBuf::gather() on the head of the queue, if it exists. methodset Capacity

headroom

Get writeable headroom methodset Access

markPrepended

Indicate that n bytes from the headroom have been used. methodset Shifting

move

Transfer ownership of the queue's entire IOBuf chain to the caller. methodset Conversions

moveAsValue

Transfer the queue's entire IOBuf chain to the caller, by value.

options

Get the options used to configure this IOBufQueue. methodset Configuration

pop_front

Removes and returns the first IOBuf in the chain. methodset Conversions

postallocate

Tell the queue that the caller has written data into the first n bytes provided by the previous preallocate() call. methodset Allocation

preallocate

Obtain a writable block of contiguous bytes at the end of this queue, allocating more space if necessary. methodset Allocation

prepend

Prepend an existing range methodset Modifiers

reset

Clear the queue, freeing all the buffers. methodset Allocation

setIOBufFactory

Set a custom IOBufFactory for buffer allocations. methodset Configuration

split

Split off the first n bytes of the queue into a separate IOBuf chain. methodset Modifiers

splitAtMost

Split at most n bytes. methodset Modifiers

tailroom

Get the amount of free space at the end of the buffer. methodset Access

trimEnd

Remove bytes from the end. methodset Shifting

trimEndAtMost

Maybe remove bytes from the end. methodset Shifting

trimStart

Remove bytes from the front. methodset Shifting

trimStartAtMost

Maybe remove bytes from the front. methodset Shifting

wrapBuffer

Append a buffer by wrapping. methodset Modifiers

writableTail

Get a pointer to the writable tail section. methodset Access

Static Member Functions

Name

Description

cacheChainLength

Get Options with cacheChainLength=true. methodset Configuration

Static Data Members

Name

Description

kMaxPackCopy

The maximum number of bytes copied per node when packing a chain.

Friends

Name

Description

folly::io::RWCursor

Read‐write cursor over an IOBuf chain.

Created with MrDocs