proxygen
|
#include <IOBufQueue.h>
Classes | |
struct | Options |
class | WritableRangeCache |
struct | WritableRangeCacheData |
Public Member Functions | |
IOBufQueue (const Options &options=Options()) | |
~IOBufQueue () | |
std::pair< void *, std::size_t > | headroom () |
void | markPrepended (std::size_t n) |
void | prepend (const void *buf, std::size_t n) |
void | append (std::unique_ptr< folly::IOBuf > &&buf, bool pack=false) |
void | append (IOBufQueue &other, bool pack=false) |
void | append (IOBufQueue &&other, bool pack=false) |
void | append (const void *buf, size_t len) |
void | append (StringPiece sp) |
void | wrapBuffer (const void *buf, size_t len, std::size_t blockSize=(1U<< 31)) |
std::pair< void *, std::size_t > | preallocate (std::size_t min, std::size_t newAllocationSize, std::size_t max=std::numeric_limits< std::size_t >::max()) |
void | postallocate (std::size_t n) |
void * | allocate (std::size_t n) |
void * | writableTail () const |
size_t | tailroom () const |
std::unique_ptr< folly::IOBuf > | split (size_t n) |
std::unique_ptr< folly::IOBuf > | splitAtMost (size_t n) |
void | trimStart (size_t amount) |
size_t | trimStartAtMost (size_t amount) |
void | trimEnd (size_t amount) |
size_t | trimEndAtMost (size_t amount) |
std::unique_ptr< folly::IOBuf > | move () |
const folly::IOBuf * | front () const |
std::unique_ptr< folly::IOBuf > | pop_front () |
size_t | chainLength () const |
bool | empty () const |
const Options & | options () const |
void | clear () |
void | appendToString (std::string &out) const |
void | gather (std::size_t maxLength) |
IOBufQueue (IOBufQueue &&) noexcept | |
IOBufQueue & | operator= (IOBufQueue &&) |
Static Public Member Functions | |
static Options | cacheChainLength () |
Private Member Functions | |
auto | updateGuard () |
std::unique_ptr< folly::IOBuf > | split (size_t n, bool throwOnUnderflow) |
IOBufQueue (const IOBufQueue &)=delete | |
IOBufQueue & | operator= (const IOBufQueue &)=delete |
void | dcheckCacheIntegrity () const |
void | fillWritableRangeCache (WritableRangeCacheData &dest) |
void | clearWritableRangeCache () |
void | flushCache () const |
void | updateCacheRef (WritableRangeCacheData &newRef) |
void | updateWritableTailCache () |
std::pair< void *, std::size_t > | preallocateSlow (std::size_t min, std::size_t newAllocationSize, std::size_t max) |
Private Attributes | |
Options | options_ |
size_t | chainLength_ {0} |
std::unique_ptr< folly::IOBuf > | head_ |
uint8_t * | tailStart_ {nullptr} |
WritableRangeCacheData * | cachePtr_ {nullptr} |
WritableRangeCacheData | localCache_ |
Static Private Attributes | |
static const size_t | kChainLengthNotCached = (size_t)-1 |
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.
You may also prepend data into the headroom of the first buffer in the chain, if any.
Definition at line 35 of file IOBufQueue.h.
Definition at line 67 of file IOBufQueue.cpp.
References folly::IOBufQueue::WritableRangeCacheData::attached, and localCache_.
Referenced by folly::IOBufQueue::WritableRangeCache::dcheckIntegrity(), and options().
folly::IOBufQueue::~IOBufQueue | ( | ) |
Definition at line 72 of file IOBufQueue.cpp.
References clearWritableRangeCache().
Referenced by folly::IOBufQueue::WritableRangeCache::dcheckIntegrity().
|
noexcept |
Definition at line 76 of file IOBufQueue.cpp.
References chainLength_, head_, folly::gen::move, and tailStart_.
|
privatedelete |
Not copyable
|
inline |
Obtain a writable block of n contiguous bytes, allocating more space if necessary, and mark it as used. The caller can fill it later.
Definition at line 392 of file IOBufQueue.h.
References postallocate(), and preallocate().
void folly::IOBufQueue::append | ( | std::unique_ptr< folly::IOBuf > && | buf, |
bool | pack = false |
||
) |
Add a buffer or buffer chain to the end of this queue. The queue takes ownership of buf.
If pack is true, we try to reduce wastage at the end of this queue by copying some data from the first buffers in the buf chain (and releasing the buffers), if possible. If pack is false, we leave the chain topology unchanged.
Definition at line 143 of file IOBufQueue.cpp.
References folly::IOBufQueue::Options::cacheChainLength, chainLength_, folly::gen::guard(), head_, folly::gen::move, options_, and updateGuard().
Referenced by proxygen::HPACKEncodeBuffer::addHeadroom(), append(), folly::AsyncSSLSocket::bioRead(), folly::io::test::compressSome(), folly::IOBufQueue::WritableRangeCache::dcheckIntegrity(), proxygen::compress::QPACKScheme::decode(), proxygen::QPACKEncoder::decodeDecoderStream(), proxygen::QPACKDecoder::decodeEncoderStream(), proxygen::QPACKDecoder::decodeStreaming(), fizz::sm::encodeAndAddBinders(), proxygen::fakeMockCodec(), proxygen::HTTP1xCodec::generateBody(), proxygen::HTTP2Codec::generateBody(), proxygen::HTTP2Codec::generateCertificate(), proxygen::HTTP1xCodec::generateChunkHeader(), proxygen::HTTP1xCodec::generateChunkTerminator(), proxygen::HTTP2Codec::generateConnectionPreface(), proxygen::SPDYCodec::generateDataFrame(), proxygen::SPDYCodec::generateSynReply(), proxygen::SPDYCodec::generateSynStream(), proxygen::HTTP2Codec::generateTrailers(), fizz::sm::getCertificateRequest(), MockCodecDownstreamTest::MockCodecDownstreamTest(), proxygen::ScopedHandler< HandlerType >::onBody(), proxygen::FakeHTTPCodecCallback::onBody(), proxygen::FakeHTTPCodecCallback::onCertificate(), proxygen::FakeHTTPCodecCallback::onCertificateRequest(), proxygen::FakeHTTPCodecCallback::onGoaway(), proxygen::RFC1867Codec::onIngress(), proxygen::HTTP2Codec::onIngressUpgradeMessage(), proxygen::HTTPSession::onPingRequest(), proxygen::parse(), proxygen::RFC1867Base::parse(), proxygen::HTTP2Codec::parseCertificate(), proxygen::HTTP2Codec::parseHeadersImpl(), proxygen::parseUnidirectional(), folly::AsyncSocket::performRead(), fizz::EncryptedReadRecordLayer::read(), fizz::AsyncFizzBase::readBufferAvailable(), proxygen::HTTPSession::readBufferAvailable(), fizz::ReadRecordLayer::readEvent(), fizz::test::LocalTransport::receiveData(), proxygen::HTTPTransaction::sendBody(), proxygen::HTTPSession::sendHeaders(), FlowControlFilterTest< initSize >::SetUp(), MockHTTPUpstreamTest::SetUp(), fizz::sm::setupSchedulerAndContext(), folly::io::test::CompressionTest::split(), TEST(), TEST_F(), MockCodecDownstreamTest::testConnFlowControlBlocked(), folly::bser::toBserIOBuf(), folly::io::test::uncompressSome(), wrapBuffer(), wangle::test::BytesReflector::write(), fizz::EncryptedWriteRecordLayer::write(), folly::AsyncPipeWriter::write(), proxygen::http2::writeCertificate(), and proxygen::http2::writeCertificateRequest().
void folly::IOBufQueue::append | ( | IOBufQueue & | other, |
bool | pack = false |
||
) |
Add a queue to the end of this queue. The queue takes ownership of all buffers from the other queue.
Definition at line 154 of file IOBufQueue.cpp.
References folly::IOBufQueue::Options::cacheChainLength, chainLength_, folly::gen::guard(), head_, folly::gen::move, options_, and updateGuard().
|
inline |
Definition at line 301 of file IOBufQueue.h.
References append().
void folly::IOBufQueue::append | ( | const void * | buf, |
size_t | len | ||
) |
Copy len bytes, starting at buf, to the end of this queue. The caller retains ownership of the source data.
Definition at line 172 of file IOBufQueue.cpp.
References folly::IOBuf::append(), chainLength_, folly::IOBuf::create(), folly::gen::guard(), head_, max, min, folly::IOBuf::tailroom(), uint8_t, updateGuard(), and folly::IOBuf::writableTail().
|
inline |
Copy a string to the end of this queue. The caller retains ownership of the source data.
Definition at line 315 of file IOBufQueue.h.
References append(), folly::Range< Iter >::data(), folly::Range< Iter >::size(), and wrapBuffer().
void folly::IOBufQueue::appendToString | ( | std::string & | out | ) | const |
Append the queue to a std::string. Non-destructive.
Definition at line 340 of file IOBufQueue.cpp.
References folly::IOBufQueue::Options::cacheChainLength, folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, chainLength_, head_, options_, folly::range(), and tailStart_.
Referenced by options(), and TEST().
|
inlinestatic |
Commonly used Options, currently the only possible value other than the default.
Definition at line 83 of file IOBufQueue.h.
References folly::IOBufQueue::Options::cacheChainLength, and options().
Referenced by proxygen::SecondaryAuthManager::createAuthRequest(), TestPriorityMapBuilder::createVirtualStreams(), folly::io::StreamCodec::doUncompress(), HTTPUpstreamTest< SPDY3CodecPair >::enableExHeader(), fizz::sm::encodeAndAddBinders(), fizz::ExportedAuthenticator::getAuthenticatorContext(), getSynStream(), fizz::server::AeadCookieCipher< AeadType, HkdfType >::getTokenOrRetry(), proxygen::HTTPSession::onPingRequest(), proxygen::parse(), proxygen::parseUnidirectional(), fizz::sm::setupSchedulerAndContext(), TEST(), TEST_F(), TEST_P(), folly::bser::toBserIOBuf(), fizz::ExportedAuthenticator::validate(), and wangle::test::BytesReflector::write().
|
inline |
Total chain length, only valid if cacheLength was specified in the constructor.
Definition at line 492 of file IOBufQueue.h.
References folly::IOBufQueue::Options::cacheChainLength, folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, chainLength_, dcheckCacheIntegrity(), options_, tailStart_, and UNLIKELY.
Referenced by fizz::AsyncFizzBase::checkBufLen(), wangle::LineBasedFrameDecoder::decode(), wangle::FixedLengthFrameDecoder::decode(), ByteToStringDecoder::decode(), wangle::LengthFieldBasedFrameDecoder::decode(), proxygen::QPACKEncoder::decodeDecoderStream(), proxygen::QPACKDecoder::decodeEncoderStream(), fizz::ReadRecordLayer::decodeHandshakeMessage(), folly::io::StreamCodec::doUncompress(), fizz::sm::encodeAndAddBinders(), wangle::LineBasedFrameDecoder::findEndOfLine(), proxygen::HTTP2Codec::generateBody(), proxygen::HTTP2Codec::generateCertificate(), proxygen::HTTP2Codec::generateContinuation(), proxygen::SPDYCodec::generateGoaway(), proxygen::SPDYCodec::generatePingCommon(), proxygen::SPDYCodec::generateRstStream(), proxygen::SPDYCodec::generateSettings(), proxygen::HTTP2Codec::generateTrailers(), proxygen::SPDYCodec::generateWindowUpdate(), fizz::EncryptedReadRecordLayer::getDecryptedBuf(), proxygen::HTTPSession::getNextToSend(), proxygen::HTTPTransaction::markEgressComplete(), proxygen::HTTPTransaction::notifyTransportPendingEgress(), proxygen::HTTPSession::onPingRequest(), proxygen::parse(), proxygen::HTTP2Codec::parseCertificate(), proxygen::HTTP2Codec::parseFrame(), proxygen::HTTP2Codec::parseHeadersDecodeFrames(), NaiveRoutingDataHandler::parseRoutingData(), proxygen::parseUnidirectional(), fizz::PlaintextReadRecordLayer::read(), proxygen::HTTPTransaction::sendDeferredBody(), proxygen::HTTPTransaction::sendEOM(), proxygen::HTTPSession::sessionByteOffset(), fizz::sm::setupSchedulerAndContext(), TEST(), folly::bser::toBserIOBuf(), and proxygen::HTTPTransaction::updateHandlerPauseState().
void folly::IOBufQueue::clear | ( | ) |
Clear the queue. Note that this does not release the buffers, it just sets their length to zero; useful if you want to reuse the same queue without reallocating.
Definition at line 327 of file IOBufQueue.cpp.
References chainLength_, folly::IOBuf::clear(), folly::gen::guard(), head_, folly::IOBuf::next(), and updateGuard().
Referenced by proxygen::HPACKEncodeBuffer::clear(), options(), proxygen::HTTP2Codec::parseCertificate(), TEST(), and TEST_F().
|
inlineprivate |
Clear current writable tail cache and reset it to localCache_
Definition at line 596 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::attached, cachePtr_, flushCache(), localCache_, and folly::gen::move.
Referenced by operator=(), and ~IOBufQueue().
|
inlineprivate |
Definition at line 559 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::attached, folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, folly::IOBuf::prev(), folly::IOBuf::tailroom(), tailStart_, and folly::IOBuf::writableTail().
Referenced by chainLength(), empty(), fillWritableRangeCache(), flushCache(), postallocate(), preallocate(), tailroom(), and writableTail().
|
inline |
Returns true iff the IOBuf chain length is 0.
Definition at line 503 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, dcheckCacheIntegrity(), head_, and tailStart_.
Referenced by folly::Subprocess::communicateIOBuf(), fizz::test::LocalTransport::deliverData(), fizz::sm::getCertificateRequest(), fizz::EncryptedReadRecordLayer::getDecryptedBuf(), proxygen::HTTPSession::getNextToSend(), folly::AsyncPipeWriter::handleWrite(), fizz::ReadRecordLayer::hasUnparsedHandshakeData(), fizz::server::looksLikeV2ClientHello(), proxygen::HTTP2Codec::parseCertificate(), fizz::PlaintextReadRecordLayer::read(), proxygen::HTTPSession::readEOF(), fizz::ReadRecordLayer::readEvent(), TEST(), and fizz::EncryptedWriteRecordLayer::write().
|
inlineprivate |
Populate dest with writable tail range cache.
Definition at line 585 of file IOBufQueue.h.
References cachePtr_, dcheckCacheIntegrity(), upload::dest, and folly::gen::move.
|
inlineprivate |
Commit any pending changes to the tail of the queue.
Definition at line 610 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, chainLength_, dcheckCacheIntegrity(), folly::IOBuf::prev(), and tailStart_.
Referenced by clearWritableRangeCache(), front(), preallocateSlow(), and updateGuard().
|
inline |
Access the front IOBuf.
Note: caller will see the current state of the chain, but may not see future updates immediately, due to the presence of a tail cache. Note: the caller may potentially clone the chain, thus marking all buffers as shared. We may still continue writing to the tail of the last IOBuf without checking if it's shared, but this is fine, since the cloned IOBufs won't reference that data.
Definition at line 476 of file IOBufQueue.h.
References flushCache(), head_, and pop_front().
Referenced by proxygen::HPACKEncodeBuffer::addHeadroom(), wangle::LineBasedFrameDecoder::decode(), proxygen::QPACKEncoder::decodeDecoderStream(), proxygen::QPACKDecoder::decodeEncoderStream(), fizz::ReadRecordLayer::decodeHandshakeMessage(), HTTPParallelCodecTest::dumpToFile(), wangle::LineBasedFrameDecoder::findEndOfLine(), fizz::EncryptedWriteRecordLayer::getBufToEncrypt(), fizz::EncryptedReadRecordLayer::getDecryptedBuf(), wangle::LengthFieldBasedFrameDecoder::getUnadjustedFrameLength(), folly::AsyncPipeWriter::handleWrite(), proxygen::HTTPSession::hasMoreWrites(), fizz::server::looksLikeV2ClientHello(), proxygen::parse(), proxygen::HTTP2Codec::parseHeadersDecodeFrames(), proxygen::parseUnidirectional(), folly::Subprocess::pid(), proxygen::HTTPSession::processReadData(), fizz::PlaintextReadRecordLayer::read(), fizz::EncryptedReadRecordLayer::read(), proxygen::HTTPSession::scheduleWrite(), TEST(), TEST_F(), TEST_P(), and proxygen::HPACKEncodeBuffer::toBin().
void folly::IOBufQueue::gather | ( | std::size_t | maxLength | ) |
Calls IOBuf::gather() on the head of the queue, if it exists.
Definition at line 361 of file IOBufQueue.cpp.
References folly::gen::guard(), head_, and updateGuard().
Referenced by options(), and TEST().
std::pair< void *, std::size_t > folly::IOBufQueue::headroom | ( | ) |
Return a space to prepend bytes and the amount of headroom available.
Definition at line 111 of file IOBufQueue.cpp.
References head_.
Referenced by folly::IOBufQueue::WritableRangeCache::dcheckIntegrity().
void folly::IOBufQueue::markPrepended | ( | std::size_t | n | ) |
Indicate that n bytes from the headroom have been used.
Definition at line 121 of file IOBufQueue.cpp.
References chainLength_, and head_.
Referenced by folly::IOBufQueue::WritableRangeCache::dcheckIntegrity().
|
inline |
Transfer ownership of the queue's entire IOBuf chain to the caller.
Definition at line 459 of file IOBufQueue.h.
References chainLength_, folly::gen::guard(), head_, folly::gen::move, and updateGuard().
Referenced by BENCHMARK(), folly::AsyncSSLSocket::bioRead(), folly::io::test::compressSome(), wangle::SimpleDecode::decode(), wangle::LineBasedFrameDecoder::decode(), ByteToStringDecoder::decode(), proxygen::QPACKDecoder::decodeStreaming(), fizz::test::LocalTransport::deliverData(), folly::io::StreamCodec::doUncompress(), proxygen::compress::QPACKScheme::encode(), fizz::sm::encodeAndAddBinders(), proxygen::HTTP2Codec::generateBody(), proxygen::HTTP2Codec::generateCertificate(), fizz::sm::getCertificateRequest(), proxygen::HTTPSession::getNextToSend(), getSynStream(), proxygen::HTTPTransaction::markEgressComplete(), proxygen::ScopedHandler< HandlerType >::onEOM(), proxygen::HTTPSession::onPingRequest(), proxygen::HTTP2Codec::parseCertificate(), proxygen::HTTP2Codec::parseHeadersDecodeFrames(), HTTPParallelCodecTest::parseImpl(), NaiveRoutingDataHandler::parseRoutingData(), proxygen::parseUnidirectional(), folly::AsyncSocket::performRead(), preallocate_postallocate_bench(), fizz::EncryptedReadRecordLayer::read(), ProxyBackendHandler::read(), ProxyService::ProxyHandler::readDataAvailable(), StaticService::StaticHandler::readFile(), proxygen::HPACKEncodeBuffer::release(), proxygen::FakeHTTPCodecCallback::reset(), runArithmeticBench(), runPushBenchmark(), proxygen::HTTPSession::sendHeaders(), fizz::sm::setupSchedulerAndContext(), HTTPParallelCodecTest::SetUpUpstreamTest(), proxygen::HTTPSession::shutdownTransportWithReset(), folly::io::test::CompressionTest::split(), TEST(), TEST_F(), folly::bser::toBserIOBuf(), and folly::io::test::uncompressSome().
IOBufQueue & folly::IOBufQueue::operator= | ( | IOBufQueue && | other | ) |
Definition at line 91 of file IOBufQueue.cpp.
References folly::IOBufQueue::WritableRangeCacheData::attached, folly::IOBufQueue::WritableRangeCacheData::cachedRange, chainLength_, clearWritableRangeCache(), head_, localCache_, folly::gen::move, options_, and tailStart_.
|
privatedelete |
|
inline |
Definition at line 509 of file IOBufQueue.h.
References appendToString(), clear(), gather(), IOBufQueue(), folly::pushmi::__adl::noexcept(), folly::IOBufQueue::WritableRangeCacheData::operator=(), options_, split(), and string.
Referenced by cacheChainLength(), and folly::IOBufQueue::WritableRangeCache::dcheckIntegrity().
std::unique_ptr< folly::IOBuf > folly::IOBufQueue::pop_front | ( | ) |
returns the first IOBuf in the chain and removes it from the chain
Definition at line 316 of file IOBufQueue.cpp.
References chainLength_, folly::gen::guard(), head_, folly::gen::move, folly::IOBuf::pop(), and updateGuard().
Referenced by TestAsyncTransport::addReadEvent(), front(), fizz::EncryptedWriteRecordLayer::getBufToEncrypt(), proxygen::HTTPSession::processReadData(), and TEST().
|
inline |
Tell the queue that the caller has written data into the first n bytes provided by the previous preallocate() call.
Definition at line 380 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, and dcheckCacheIntegrity().
Referenced by allocate(), folly::IOBufQueue::WritableRangeCache::appendSlow(), folly::io::StreamCodec::doUncompress(), proxygen::SPDYCodec::generateDataFrame(), proxygen::HTTP1xCodec::generateHeader(), folly::AsyncUDPServerSocket::onDataAvailable(), folly::Subprocess::pid(), preallocate_postallocate_bench(), ProxyService::ProxyHandler::readDataAvailable(), wangle::AsyncSocketHandler::readDataAvailable(), fizz::AsyncFizzBase::readDataAvailable(), proxygen::HTTPSession::readDataAvailable(), StaticService::StaticHandler::readFile(), and TEST().
|
inline |
Obtain a writable block of contiguous bytes at the end of this queue, allocating more space if necessary. The amount of space reserved will be at least min. If min contiguous space is not available at the end of the queue, and IOBuf with size newAllocationSize is appended to the chain and returned. The actual available space may be larger than newAllocationSize, but will be truncated to max, if specified.
If the caller subsequently writes anything into the returned space, it must call the postallocate() method.
Definition at line 356 of file IOBufQueue.h.
References dcheckCacheIntegrity(), LIKELY, max, preallocateSlow(), tailroom(), and writableTail().
Referenced by allocate(), folly::io::StreamCodec::doUncompress(), proxygen::HTTP1xCodec::generateHeader(), ProxyService::ProxyHandler::getReadBuffer(), wangle::AsyncSocketHandler::getReadBuffer(), folly::AsyncUDPServerSocket::getReadBuffer(), fizz::AsyncFizzBase::getReadBuffer(), proxygen::HTTPSession::getReadBuffer(), folly::Subprocess::pid(), preallocate_postallocate_bench(), StaticService::StaticHandler::readFile(), TEST(), and TEST_F().
|
private |
Definition at line 207 of file IOBufQueue.cpp.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, folly::IOBuf::create(), flushCache(), head_, max, folly::gen::move, tailroom(), tailStart_, and writableTail().
Referenced by preallocate(), and updateWritableTailCache().
void folly::IOBufQueue::prepend | ( | const void * | buf, |
std::size_t | n | ||
) |
Prepend an existing range; throws std::overflow_error if not enough room.
Definition at line 132 of file IOBufQueue.cpp.
References chainLength_, and head_.
Referenced by folly::IOBufQueue::WritableRangeCache::dcheckIntegrity(), TEST(), and folly::bser::toBserIOBuf().
|
inline |
Split off the first n bytes of the queue into a separate IOBuf chain, and transfer ownership of the new chain to the caller. The IOBufQueue retains ownership of everything after the split point.
std::underflow_error | if n exceeds the number of bytes in the queue. |
Definition at line 420 of file IOBufQueue.h.
Referenced by wangle::LineBasedFrameDecoder::decode(), wangle::FixedLengthFrameDecoder::decode(), wangle::LengthFieldBasedFrameDecoder::decode(), fizz::ReadRecordLayer::decodeHandshakeMessage(), fizz::test::LocalTransport::deliverData(), fizz::sm::encodeAndAddBinders(), proxygen::HTTP2Codec::generateBody(), proxygen::HTTP2Codec::generateContinuation(), proxygen::HTTP2Codec::generateTrailers(), proxygen::HTTPSession::getNextToSend(), folly::AsyncUDPServerSocket::onDataAvailable(), options(), proxygen::parse(), proxygen::HTTPTransaction::sendDeferredBody(), fizz::sm::setupSchedulerAndContext(), splitAtMost(), and TEST().
|
private |
Definition at line 223 of file IOBufQueue.cpp.
References chainLength_, folly::IOBuf::create(), folly::gen::guard(), head_, folly::gen::move, UNLIKELY, and updateGuard().
|
inline |
Similar to split, but will return the entire queue instead of throwing if n exceeds the number of bytes in the queue.
Definition at line 428 of file IOBufQueue.h.
References split(), trimEnd(), trimEndAtMost(), trimStart(), and trimStartAtMost().
Referenced by proxygen::HTTP2Codec::generateCertificate(), fizz::EncryptedWriteRecordLayer::getBufToEncrypt(), fizz::sm::getCertificateRequest(), fizz::PlaintextReadRecordLayer::read(), and TEST().
|
inline |
Definition at line 403 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, and dcheckCacheIntegrity().
Referenced by proxygen::SPDYCodec::generateDataFrame(), preallocate(), preallocateSlow(), and folly::io::test::uncompressSome().
void folly::IOBufQueue::trimEnd | ( | size_t | amount | ) |
Similar to IOBuf::trimEnd, but works on the whole queue. Will pop off buffers that have been completely trimmed.
Definition at line 283 of file IOBufQueue.cpp.
References trimEndAtMost().
Referenced by fizz::EncryptedReadRecordLayer::read(), splitAtMost(), and TEST().
size_t folly::IOBufQueue::trimEndAtMost | ( | size_t | amount | ) |
Similar to trimEnd, but will trim at most amount bytes and returns the number of bytes trimmed.
Definition at line 291 of file IOBufQueue.cpp.
References chainLength_, folly::gen::guard(), head_, and updateGuard().
Referenced by splitAtMost(), TEST(), and trimEnd().
void folly::IOBufQueue::trimStart | ( | size_t | amount | ) |
Similar to IOBuf::trimStart, but works on the whole queue. Will pop off buffers that have been completely trimmed.
Definition at line 255 of file IOBufQueue.cpp.
References trimStartAtMost().
Referenced by folly::AsyncSSLSocket::bioRead(), wangle::LineBasedFrameDecoder::decode(), wangle::LengthFieldBasedFrameDecoder::decode(), proxygen::QPACKEncoder::decodeDecoderStream(), proxygen::QPACKDecoder::decodeEncoderStream(), proxygen::QPACKDecoder::decodeStreaming(), fizz::EncryptedReadRecordLayer::getDecryptedBuf(), folly::AsyncPipeWriter::handleWrite(), folly::AsyncSocket::performRead(), folly::Subprocess::pid(), proxygen::HTTPSession::processReadData(), fizz::PlaintextReadRecordLayer::read(), splitAtMost(), and TEST().
size_t folly::IOBufQueue::trimStartAtMost | ( | size_t | amount | ) |
Similar to trimStart, but will trim at most amount bytes and returns the number of bytes trimmed.
Definition at line 263 of file IOBufQueue.cpp.
References chainLength_, folly::gen::guard(), head_, and updateGuard().
Referenced by wangle::LengthFieldBasedFrameDecoder::decode(), splitAtMost(), TEST(), and trimStart().
|
inlineprivate |
|
inlineprivate |
This guard should be taken by any method that intends to do any changes to in data_ (e.g. appending to it).
It flushes the writable tail cache and refills it on destruction.
Definition at line 43 of file IOBufQueue.h.
References flushCache(), folly::makeGuard(), and updateWritableTailCache().
Referenced by append(), clear(), gather(), move(), pop_front(), split(), trimEndAtMost(), and trimStartAtMost().
|
inlineprivate |
Update cached writable tail range. Called by updateGuard()
Definition at line 633 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, folly::IOBuf::isSharedOne(), LIKELY, max, preallocateSlow(), folly::IOBuf::prev(), folly::IOBuf::tailroom(), tailStart_, and folly::IOBuf::writableTail().
Referenced by updateGuard().
void folly::IOBufQueue::wrapBuffer | ( | const void * | buf, |
size_t | len, | ||
std::size_t | blockSize = (1U << 31) |
||
) |
Append a chain of IOBuf objects that point to consecutive regions within buf.
Just like IOBuf::wrapBuffer, this should only be used when the caller knows ahead of time and can ensure that all IOBuf objects that will point to this buffer will be destroyed before the buffer itself is destroyed; all other caveats from wrapBuffer also apply.
Every buffer except for the last will wrap exactly blockSize bytes. Importantly, this method may be used to wrap buffers larger than 4GB.
Definition at line 194 of file IOBufQueue.cpp.
References append(), min, uint8_t, and folly::IOBuf::wrapBuffer().
Referenced by append(), folly::Subprocess::communicate(), and TEST().
|
inline |
Definition at line 398 of file IOBufQueue.h.
References folly::IOBufQueue::WritableRangeCacheData::cachedRange, cachePtr_, and dcheckCacheIntegrity().
Referenced by preallocate(), and preallocateSlow().
|
private |
Definition at line 556 of file IOBufQueue.h.
Referenced by appendToString(), chainLength(), clearWritableRangeCache(), dcheckCacheIntegrity(), empty(), fillWritableRangeCache(), flushCache(), postallocate(), preallocateSlow(), tailroom(), updateCacheRef(), updateWritableTailCache(), and writableTail().
|
mutableprivate |
Definition at line 547 of file IOBufQueue.h.
Referenced by append(), appendToString(), chainLength(), clear(), flushCache(), IOBufQueue(), markPrepended(), move(), operator=(), pop_front(), prepend(), split(), trimEndAtMost(), and trimStartAtMost().
|
private |
Everything that has been appended but not yet discarded or moved out Note: anything that needs to operate on a tail should either call flushCache() or grab updateGuard() (it will flush the cache itself).
Definition at line 553 of file IOBufQueue.h.
Referenced by append(), appendToString(), clear(), folly::IOBufQueue::WritableRangeCache::dcheckIntegrity(), empty(), front(), gather(), headroom(), IOBufQueue(), markPrepended(), move(), operator=(), pop_front(), preallocateSlow(), prepend(), split(), trimEndAtMost(), and trimStartAtMost().
|
staticprivate |
Definition at line 537 of file IOBufQueue.h.
|
private |
Definition at line 557 of file IOBufQueue.h.
Referenced by clearWritableRangeCache(), IOBufQueue(), and operator=().
|
private |
Definition at line 542 of file IOBufQueue.h.
Referenced by append(), appendToString(), chainLength(), operator=(), and options().
Definition at line 555 of file IOBufQueue.h.
Referenced by appendToString(), chainLength(), dcheckCacheIntegrity(), empty(), flushCache(), IOBufQueue(), operator=(), preallocateSlow(), and updateWritableTailCache().