proxygen
|
#include <IOBufQueue.h>
Public Member Functions | |
WritableRangeCache (folly::IOBufQueue *q=nullptr) | |
WritableRangeCache (WritableRangeCache &&other) | |
WritableRangeCache & | operator= (WritableRangeCache &&other) |
WritableRangeCache (const WritableRangeCache &other) | |
WritableRangeCache & | operator= (const WritableRangeCache &other) |
~WritableRangeCache () | |
void | reset (IOBufQueue *q) |
IOBufQueue * | queue () |
uint8_t * | writableData () |
size_t | length () |
void | append (size_t n) |
void | appendUnsafe (size_t n) |
void | fillCache () |
Private Member Functions | |
FOLLY_NOINLINE void | appendSlow (size_t n) |
void | dcheckIntegrity () |
Private Attributes | |
WritableRangeCacheData | data_ |
IOBufQueue * | queue_ |
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).
The cache is flushed on destruction/copy/move and on non-const accesses to the underlying IOBufQueue.
Note: there can be only one active cache for a given IOBufQueue, i.e. when you fill a cache object it automatically invalidates other cache (if any).
Definition at line 101 of file IOBufQueue.h.
|
inlineexplicit |
Definition at line 103 of file IOBufQueue.h.
|
inline |
Move constructor/assignment can move the cached range, but must update the reference in IOBufQueue.
Definition at line 113 of file IOBufQueue.h.
References data_.
|
inline |
Copy constructor/assignment cannot copy the cached range.
Definition at line 137 of file IOBufQueue.h.
|
inline |
Definition at line 149 of file IOBufQueue.h.
References data_.
|
inline |
Mark n bytes as occupied (e.g. postallocate).
Definition at line 200 of file IOBufQueue.h.
|
inlineprivate |
|
inline |
Same as append(n), but avoids checking if there is a cache. The caller must guarantee that the cache is set (e.g. the caller just called fillCache or checked that it's not empty).
Definition at line 218 of file IOBufQueue.h.
References data_.
|
inlineprivate |
Definition at line 237 of file IOBufQueue.h.
References folly::IOBufQueue::append(), folly::IOBufQueue::WritableRangeCacheData::attached, folly::IOBufQueue::WritableRangeCacheData::cachedRange, folly::IOBufQueue::head_, folly::IOBufQueue::headroom(), folly::IOBufQueue::IOBufQueue(), folly::IOBufQueue::markPrepended(), folly::IOBufQueue::options(), folly::IOBufQueue::prepend(), and folly::IOBufQueue::~IOBufQueue().
|
inline |
Fill the cache of writable tail from the underlying IOBufQueue.
Definition at line 225 of file IOBufQueue.h.
References data_.
|
inline |
Return a length of cached writable tail.
Note: doesn't populate cache.
Definition at line 192 of file IOBufQueue.h.
References data_.
|
inline |
Definition at line 119 of file IOBufQueue.h.
References data_, and folly::gen::move.
|
inline |
Definition at line 139 of file IOBufQueue.h.
|
inline |
|
inline |
Reset the underlying IOBufQueue, will flush current cache if present.
Definition at line 158 of file IOBufQueue.h.
References data_.
|
inline |
Return a pointer to the start of cached writable tail.
Note: doesn't populate cache.
Definition at line 182 of file IOBufQueue.h.
References data_.
|
private |
Definition at line 230 of file IOBufQueue.h.
|
private |
Definition at line 231 of file IOBufQueue.h.
Referenced by operator=().