/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
void trimStart(size_t amount);
+ /**
+ * Similar to trimStart, but will trim at most amount bytes and returns
+ * the number of bytes trimmed.
+ */
+ size_t trimStartAtMost(size_t amount);
+
/**
* Similar to IOBuf::trimEnd, but works on the whole queue. Will
* pop off buffers that have been completely trimmed.
*/
void trimEnd(size_t amount);
+ /**
+ * Similar to trimEnd, but will trim at most amount bytes and returns
+ * the number of bytes trimmed.
+ */
+ size_t trimEndAtMost(size_t amount);
+
/**
* Transfer ownership of the queue's entire IOBuf chain to the caller.
*/
private:
IOBuf* tailBuf() const {
- if (UNLIKELY(!head_)) return nullptr;
+ if (UNLIKELY(!head_)) {
+ return nullptr;
+ }
IOBuf* buf = head_->prev();
return LIKELY(!buf->isSharedOne()) ? buf : nullptr;
}
std::unique_ptr<folly::IOBuf> head_;
};
-} // folly
+} // namespace folly